Hi support Team, I’m currently trying to use Aspose.cells to read a HTML spreadsheet however during the reading of this file the leading zeros of the numbers in the data is removed.
I believe this is due to Aspose trying to read the data as a number type. At the moment I’ve been forced to use a workaround in which I appending an apostrophe to the front of the numbers seems to force Aspose to read the values a string however this is not ideal.
When using the in browser Aspose Convert function to convert the html file to an xls it also removes the leading zeros.
Since I’m unable to upload the HTML format to this ticket I’ve included an image what the HTML spreadsheet looks like below:
image.png (2.4 KB)
Do you have any suggestions on how to fix this issue?
@Adeniyi.Adedoyin,
Thanks for the screenshot.
Please zip your HTML and attach it here again.
By the way, could you please try to specify ConvertNumericData attribute to “false” while loading HTML options if it makes any difference, see the following sample code
e.g.
Sample code:
// Instantiate LoadOptions specified by the LoadFormat.
HtmlLoadOptions loadOptions = new HtmlLoadOptions(LoadFormat.Html);
loadOptions.ConvertNumericData = false;
loadOptions.ConvertDateTimeData = false;
// Create a Workbook object and opening the file from its path
Workbook wb = new Workbook(filePath, loadOptions);
............
Hi Amjad,
Thank you for the swift response. I’ve attached the files as requested and I shall try the code suggested below.
LeadingZerosExample.zip (5.38 KB)
@Adeniyi.Adedoyin,
Thanks for the HTML file.
I tested using your HTML with the following sample code and it works fine. The loading zeros are not removed in the output XLSX file:
e.g.
Sample code:
// Instantiate LoadOptions specified by the LoadFormat.
HtmlLoadOptions loadOptions = new HtmlLoadOptions(LoadFormat.Html);
loadOptions.ConvertNumericData = false;
loadOptions.ConvertDateTimeData = false;
// Create a Workbook object and opening the file from its path
Workbook wb = new Workbook("e:\\test2\\LeadingZerosExample.html", loadOptions);
wb.Save("e:\\test2\\out1.xlsx", SaveFormat.Xlsx);
Hope, this helps a bit.
1 Like