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?

Hi,

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();
workbook.Open(“f:\test\percissue.xls”);
Worksheet grid = workbook.Worksheets[0];
Aspose.Cells.Cell cell = grid.Cells[0,0];
MessageBox.Show(cell.Style.Number.ToString()); //10 --> “0.00%”
MessageBox.Show(cell.Value.ToString());
MessageBox.Show(cell.StringValue);



Thank you.

Thank You