Hi,
I am using Aspose Version 8.4.2.0 to convert dynamic HTML string to excel(xlsx/xls) file. There also includes external css. In the Method, the html string is dynamic. For different report the html string will be different. So after getting the report I am attaching my external stylesheet to it and trying to pass it to excel to generate the result.
Here the main code we are using is:
Response.AddHeader(“Content-Type”, “application/octet-stream”);
Response.AppendHeader(“content-disposition”, “attachment;filename=”" + reportFileName + “_” + DateTime.Now.ToString(“MMddyyyyHHmmss”,
CultureInfo.InvariantCulture) + “.xls”");
Response.ContentType = “application/vnd.ms-excel”;
HTMLLoadOptions options = new HTMLLoadOptions(LoadFormat.Html);
byte[] byteArray = Encoding.ASCII.GetBytes(html);
MemoryStream stream = new MemoryStream();
stream.Read(byteArray, 0, byteArray.Length);
Workbook book = new Workbook(stream, options);
book.Save(stream, new XlsSaveOptions(SaveFormat.Excel97To2003));
Using this code I am able to generate the report, but while opening the report I am getting a warning message “The File Format and extension don’t match. The file could be corrupted or unsafe”.
The only reason I am using Aspose is so that we don’t get this warning message. Can you help me resolve this issue?Need fast resolution.
Thanks