We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Write exponential values to a cell

Hi,

I can’t add exponential values to a cell in Excel.
With Excel i just have to format the cell to ‘numeric’ and enter e.g. ‘1E+2’.
It will automatically displays 100,00.

How can i do it with Aspose.Cells.
I tried it with this code:

xlsLic.SetLicense(“Aspose.Total.lic”);

//Define a new Workbook.
Workbook workbook;

workbook = new Workbook();
Object test = “1E+2”;

workbook.Worksheets[0].Cells[0, 0].GetStyle().Number = 1;
workbook.Worksheets[0].Cells[0, 0].PutValue(test);
workbook.Save(“efunction.xlsx”);

But it doesn’t show 100. It still shows “1E+2”.

How can i solve this problem.

Kind regards,
Guido

Hi Guido,

Thanks for your posting and using Aspose.Cells.

Please use the following code, it will show 100 in cell A1. It is using Cell.PutValue() overload that takes a string input and converts to number if possible.

I have also attached the output xlsx file generated by this code for your reference.

C#


Workbook workbook = new Workbook();

String test = “1E+2”;


workbook.Worksheets[0].Cells[0, 0].GetStyle().Number = 1;

workbook.Worksheets[0].Cells[0, 0].PutValue(test, true);

workbook.Save(“efunction.xlsx”);