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

Free Support Forum - aspose.com

Problem with reading formats of Cells with percent

Reading on different cells in an excel worksheet with custom number formats

I got a problem with numbers in ‘percent’.

The cell contains following properties:

in Excel I got:

Numberformat: 0.00%

Value2: 1.2512

Text: 125.12 %

When I read this cell with Aspose.Cells

  • CustomStyle is empty.

  • CellValue is “1.2512”

  • CellText is “125.12%”

How can I get the Numberformat: 0.00% with Aspose.Cells?


Well, “0.00%” is one of the built-in number format, see the table in the document: http://www.aspose.com/documentation/.net-components/aspose.cells-for-.net/setting-display-formats-of-numbers-dates.html So, you may use Cell.Style.Number (instead of Cell.Style.Custom) attribute to get the the number format value (i.e. 10).

Following is my sample code.

Workbook workbook = new Workbook();
Worksheet grid = workbook.Worksheets[0];
Aspose.Cells.Cell cell = grid.Cells[0,0];
MessageBox.Show(cell.Style.Number.ToString()); //10 --> “0.00%”

Thank you.

Thank You