I dont get my number formated as NUmbers


I use sheet.Cells[1, 2].Style.Number = 4; to style my format in excel as number. It works only if the number i use as input have fraction, and if its a whole number i get it in excel as a string.

the number i try to put in the cell is 15,42 then i got the formation as a number in excel
but if the number is 15,00 u get 15 as a string and not 15,00 as number



Hi Tjiper,

I don’t find the issue using your scenario a bit. To get the value from a cell in the sheet, you may use Cell.StringValue attribute.

If you still could not figure it out, kindly give us your sample code with the template file(s), we will check it soon.

Thank you.

i am trying to write a number that is formated as a number in excel. and i am getting it as a string in excel if its a a whole number.


Thank you for considering Aspose.

Well, I have tried to implement your scenario and it works fine. Please see my sample code,

Sample Code:

//Instantiating a Workbook object

Workbook workbook = new Workbook();

//Adding a new worksheet to the Workbook object


//Obtaining the reference of the newly added worksheet by passing its sheet index

Worksheet worksheet = workbook.Worksheets[0];

//Adding the current system date to "A1" cell


//Setting the display format of the cell to number 4

worksheet.Cells[2,1].Style.Number = 4;

//Saving the Excel file

workbook.Save("C:\\book1.xls", FileFormatType.Default);

If you still face any confusion, please share your code and template file (As suggested by Amjad), we will look into it.

Thank You & Best Regards,

thanks for your support.

i had the same code above, but i didnt convert the number i had to a double before i place it in the cell, but now since i convert it to a double it works. :slight_smile: