Free Support Forum - aspose.com

Long number to scientific notation while converting HTML to Excel

Hi,

We recently found a issue where Long number was changed to scientific notation like 1.2408E+12.

So this causes an issue for us when converting back to long.
Can the Aspose left it as given in HTML. Attaching you HTML file for the reference.

Thanks
Rajo Singh.
CAD=AOApgmov94Z_bZ9txfSP-YtsM1x6FYu-CZAG7sX4sa5nCYQ@mail.gmail.com_1.zip (11.6 KB)


This Topic is created by Amjad_Sahi using the Email to Topic plugin.

@rajosingh,

Thanks for providing us template file.

I have evaluated your scenario/case a but using your template file and following sample code. Well, if you could open your template HTML into MS Excel manually, you will also see those long numbers are changed to scientific notations. This is MS Excel’s behavior and nothing to do with Aspose.Cells APIs. See the screenshot for your reference:

If you got to display full long numbers, you have to apply number formatting or custom formatting as “0”, then all those cells will display long numbers fully.
e.g
Sample code:

HTMLLoadOptions opts = new HTMLLoadOptions(LoadFormat.HTML);
		opts.setAutoFitColsAndRows(true);
		Workbook workbook = new Workbook("F:\\Files\\CAD=AOApgmov94Z_bZ9txfSP-YtsM1x6FYu-CZAG7sX4sa5nCYQ@mail.gmail.com_1\\CompleteEmail.html", opts);
		
		String output = "F:\\Files\\CAD=AOApgmov94Z_bZ9txfSP-YtsM1x6FYu-CZAG7sX4sa5nCYQ@mail.gmail.com_1\\out1.xlsx";
		workbook.save(output);

Hope, this helps a bit.

Thanks @Amjad_Sahi, for the quick response.
but how I can get the String output as mentioned below.

String output = “F:\Files\CAD=AOApgmov94Z_bZ9txfSP-YtsM1x6FYu-CZAG7sX4sa5nCYQ@mail.gmail.com_1\out1.xlsx”;

I am using this code attached. But still issue persist.
Also Aspose jar version is aspose-cells-18.6.jar

com.aspose.cells.License license = new com.aspose.cells.License();
license.setLicense(this.getClass().getClassLoader()
.getResourceAsStream(“Aspose.Cells.lic”));

// Read and create the instance of HTML file from specified location
HTMLLoadOptions options = new HTMLLoadOptions(LoadFormat.HTML);
options.setAutoFitColsAndRows(true);
Workbook book;
try {
	book = new Workbook(htmlFileLocation + File.separatorChar
			+ htmlFileName + ".html", options);
	// To check if the excel file should be .xls or .xlsx

	int saveFormat = 0;
	if (fileExtensionName != null
			&& !fileExtensionName.trim().equals("")) {
		if (fileExtensionName.trim().equalsIgnoreCase("xlsx")) {
			saveFormat = SaveFormat.XLSX;

		} else if (fileExtensionName.trim().equalsIgnoreCase("xls")) {
			saveFormat = SaveFormat.EXCEL_97_TO_2003;
		}
	}
	// save the excel file
	book.save(excelFileLocation + File.separatorChar + excelFileName
			+ "." + fileExtensionName, saveFormat);

Hi @Amjad_Sahi,

Kindly reply .

Thanks
Rajo Singh.

@rajosingh,

As I told you have to pick those cells (you may try find/search options https://docs.aspose.com/display/cellsjava/Find+or+Search+Data) for it too.) and apply formatting (i.e., custom --> “0” or built-in --> 1) to apply numbers formatting or even you may apply Text formatting to those cells, so your underlying data/value should be displayed completely and not in scientific notations. See the documents with examples (on how to apply numbers formatting upon data) for your reference:
https://docs.aspose.com/display/cellsnet/Data+Formatting#DataFormatting-UsingBuilt-inNumberFormats
https://docs.aspose.com/display/cellsnet/Data+Formatting#DataFormatting-UsingCustomNumberFormats

Hope, this helps a bit.