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

Free Support Forum - aspose.com

Read the NumberFormat of a Cell

Hi there,

in Excel/VBA I can write:

if tc.NumberFormat = “;;;” then

where tc is a range (in this case a cell).

How do I read this Format in Aspose.cell for Dot.Net. I Cant figure it out. I found Setting NumberFormat but not reading it.

Thanks in Advance
Norman

@norman.neubert

Thanks for considering Aspose APIs.

MS Excel styles are of two types

  • Built-in
  • Custom

Please use Style.Number for Built-in Styles and Style.Custom for Custom Styles.

You can get the style object of any cell like this

Style st = cell.GetStyle();

Now first check Style.Number property like this

Console.WriteLine(st.Number)

If it prints some number greater than 0, then it means, Cell has a Built-in style but if it prints 0, then it means Cell has a Custom style, so you should now use Style.Custom property

if(st.Number == 0)
    Console.WritleLine(st.Custom);

For more information, please see this article for your help