If I download an .xlsx document every empty space will be filled with a diamond that has a question mark inside it.
What I am doing is:
I have a html string of a .xlsx document that I convert it to a Workbook using:
Aspose.Cells.LoadOptions loadOptions = new Aspose.Cells.LoadOptions(Aspose.Cells.LoadFormat.Html);
System.IO.Stream stream = new System.IO.MemoryStream(ASCIIEncoding.Default.GetBytes(sourceHTML));
Aspose.Cells.Workbook wb = new Aspose.Cells.Workbook(stream, loadOptions);
I then save that workbook to a memorystream so that I could download the document:
I tried using:
xlsx.Save(this.Response, documentName, ContentDisposition.Inline, new XlsSaveOptions());
but everytime I opened that document, it would give me an error “Excel cannot open the file because the file format is invalid”.
I am using Aspose.Cells 20.6 and .NET Framework 4.5.2
I attached the .xlsx document that shows the diamond with the question mark inside. Example.zip (6.4 KB)
Please try using our latest version/fix (e.g. Aspose.Cells for .NET 21.10) for your scenario/case. In case, you still find the issue using the latest version/fix, kindly do provide us source HTML file, so we could evaluate your issue precisely on our end.
Your line of code is wrong. Please try the following line instead: xlsx.Save(this.Response, documentName, ContentDisposition.Inline, new OoxmlSaveOptions(SaveFormat.Xlsx));
I attached a screenshot of the differences. On the left is the html string opened using Microsoft Excel and on the right is the .xslx document made from the html string using Workbook.
I don’t get why the document on the left has no question marks but on the right, it does. And what could I do to not have question marks anymore.
Do you need to get XLSX file with same results/data as shown in your left side (of your attached screenshot)? I did test your scenario/ case using our latest version/fix (Aspose.Cells for .NET 21.10.x) with the following simplest lines of code in an ASP.NET application and it works same as per the results in your left hand side of your screenshot:
e.g. Sample code:
string documentName = "out1.xlsx";
Workbook workbook = new Workbook(stringHtmlFile, new LoadOptions(LoadFormat.Html));
workbook.Save(this.Response, documentName, ContentDisposition.Inline, new OoxmlSaveOptions(SaveFormat.Xlsx));
Please find attached the output XLSX file for your reference. files1.zip (6.9 KB)