Question Locked

HTML to Excel for import

0 helpful
6 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I export a grid to excel, but when i use the same excel for upload i get an error "table is not in expected format" because the type of exported excel is .html file...
how can i change the file type to .xls programmatically...Thanx

6 replies

by marv732

What are you exporting from and how?
Do you save the file and if so, in what format?
What are you tryng to upload to and how?

No one can help you if you don't explain exactly what you are doing and what you are trying to achieve

Give us some more info and we may be able to help

Greg

by fun_seeker33

I'm exporting one grid with just headers... the user will save the excel file on his machine, fill the excel with some data and upload the same excel which has the type of html.. thnx in advance...

by marv732

that I work alongside you and have a complete knowledge and understanding of your environment. Well, I don't!!!

"I'm exporting one grid with just headers" implies you have a data store of some kind (database? - if so which kind : Oracle, MS, IBM? and how do you export? this data?) and do I assume you mean you only get 1 row with column headers and if so are they static or variable?

"the user will save the excel file on his machine" - if a user saves an Excel spreadsheet then it's an Excel spreadsheet unless you mean they save it as something else (if so what format? and why save it as some other format when you need it to be an Excel spreadsheet?)

"fill the excel with some data" - now THAT I understand. (I hope... if it means the user adds some data into the spreadsheet under the column headings ? mentioned above)

"upload the same excel which has the type of html" - how can it be an Excel spreadsheet and an HTML file at the same time?? and how are they uploading it and to what - another database, a web site or what?

You need to sit down and create a list of steps that show EXACTLY what is going on in this process before ANYONE can even THINK about helping you. You might even be able to sort it out yourself that way.

Greg

by fun_seeker33

Sorry for not being so clear...
I'll explain each step now...
1. I fetch the data from SQL Server database in a gridview...(No Issue in that)
2. Now I am using Export to excel with following code:
Protected Sub btnDownloadTemplate_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnDownloadTemplate.Click

Dim excelStringWriter As New StringWriter()
Dim excelHTMLTextWriter As Html32TextWriter = New Html32TextWriter(excelStringWriter)
grvRoster.BackColor = Drawing.Color.White
grvRoster.HeaderStyle.BackColor = Drawing.Color.Black
grvRoster.RenderControl(excelHTMLTextWriter)
Response.ContentType = Constants.excelContentType
Response.AddHeader(Constants.excelContentDisposition, "inline;filename=ConfigureProcessShift.xls")
Response.Charset = Constants.SPACE
Response.Write(excelStringWriter.ToString())
Response.End()
End Sub

3. This exported spreadsheet is abc.xls, but the type of this file is html because whenever we export a gridview it is of html format. If u want to check it then export a gridview and then open the same and say "save as" there you can see the type as (html)...
4.The user fills data in this spreadsheet and uploads it, which is the problem.

5.To upload the data i need the type of the file to be xls(excel sheet) not html...
6. Is there any way to change the file type to xls while exporting..?

Thanx...

by marv732

1. Add to the macro to do a "Save As" to save it as ConfigureProcessShift.xls before the user adds their data to it?
or
2. Amend the process for the user to do a "Save As"?

Greg

This discussion is closed to new replies.