Get Help:Ask a Question in our Forums|Report a Bug|More Help Resources
Last post Dec 06, 2012 03:37 PM by jaromedubois
Jan 30, 2012 10:11 AM|LINK
I have the below piece of code using which I am able to successfully export data into an Excel 2003 file (.xls file). Currently I would need to export the HTML data to excel 2010(.xlsx) format
Response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"
Response.AddHeader("Content-Disposition", "attachment; filename=report.xlsx")
Dim strw As New System.IO.StringWriter()
Dim htmlw As New HtmlTextWriter(strw)
strw.GetStringBuilder.Append("<td colspan=9 align=left>")
strw.GetStringBuilder.Append("TEST HTML Data")
This piece of code gave me the below error and it didn't open the excel sheet
"Excel cannot open the file 'Test.xlsx' because the file format or
file extension is not valid. Verify that the file has not been
corrupted and the file extension matches the format of the file."
I read in some articles that HTML contants are not supported in excel 2007 and excel 2010, is that true? are there any work around for this issue?
In the Response.AddHeader I have used the extention as ".xls", in this case it gave me a different warning message but finally it opened the data in excel (but the file is in 2003 format). Is there any way to supress this warning message, other than changing
any registry values.
Could anyone please help me with the change required. This is a critial issue for my application, any help in this is greatly appreciated.
Sarun P S
Jan 30, 2012 11:41 AM|LINK
Instead of saving it as an .XLSX file, save it as .XLS file.
Response.AddHeader("Content-Disposition", "attachment; filename=report.xls")
Jan 30, 2012 12:39 PM|LINK
Jan 31, 2012 04:53 AM|LINK
Refer these links:
Jan 31, 2012 05:46 AM|LINK
Is there any way to hide this warning message from the .net code, other than adding the registry key. Since it is a web application, creating the registry key in all the client machines is not possible.
Jan 31, 2012 06:16 AM|LINK
I didn't found any solution to be implemented in .Net .
If you get it, please post here.
Dec 06, 2012 03:37 PM|LINK
Here, I tried this .NET library and it worked.