Cell fortmat type

Hi,


Is there any way to get the number format type of a cell within a given range? Say Fraction/Scientific/Number/Percent/DateTime/Date/Time/Text/General etc..


Regards,

Nivas.


3 Replies 1 reply marked as answer

KK Konduru Keerthi Konduru Ravichandra Raju Syncfusion Team July 12, 2022 10:29 AM UTC

Hi Nivas,


Greetings from Syncfusion.


You can get the number format that is assigned to an Excel cell, through the NumberFormat property of IRange. But, XlsIO does not have support to provide the number format type.


Please find the code snippet below.


string numberFormat = worksheet.Range[“A1”].NumberFormat;


Please go through the below documentation to know more about Syncfusion XlsIO.

https://help.syncfusion.com/file-formats/xlsio/overview


Regards,

Keerthi.



NI Nivas July 12, 2022 01:09 PM UTC

Hi Keerthi, 


I have tried that. But the thing is, say if the cell is of type date, in excel there're lot date formats like "m/d/yyyy",  "[$-F800]dddd,mmmm dd,yyyy", "d-mmm" etc.. we can't check for each and every format and verify whether it is a valid date or not. So instead of NumberFormat property, don't we have any other property or method which can return a generic data type instead of a formatted string.


Thanks, 

Nivas.



RS Ramya Sivakumar Syncfusion Team July 13, 2022 01:23 PM UTC

Hi Nivas,


We don’t have any property to get the format of the cell directly. So, we have prepared the sample to get the number format of the cell. Kindly try this and let us know if it helps.


The complete sample can be downloaded from the below link.

Sample link - https://www.syncfusion.com/downloads/support/directtrac/general/ze/Sample-2058647045


Regards,

Ramya


Marked as answer
Loader.
Up arrow icon