S
s_schutte
Hello,
I'm currently having an issue dealing with number/date formatting in
Excel. I have a C# winforms application which uses a third party
component (GemBox) to open and read Excel files without having to
instantiate Excel.
The problem I'm running into is that from this control, when I look at
a cell containing a date value, I get back a C# DateTime object. If
the value visibile in Excel is "12/1/2000", I get back "12/1/2000
12:00:00 AM" (the date plus the time).
Now, for each cell, there is a property called "NumberFormat" that
gives me the format that Excel is using to display the cell. In the
above date's case, the NumberFormat is "M/D/YY".
Now, the quick hack is to convert "M/D/YY" into "MM/dd/yyyy" and use
string.Format() in C# to display the date as "12/1/2000". However,
from what I have read, the string that Excel can return for its date
format (M/D/YY) can vary from culture to culture, and the app I am
developing must support many different international formats. (For
instance, I have read that in Italy, the date format might come back
as "aa/mm/gggg" or some craziness).
So what I was wondering is:
1. Has anyone ran into this situation before and been able to solve it
2. Does anyone have a table of all the different format strings Excel
uses, so I at least can try to parse them properly?
OR
3. Does anyone know of a third party control that can get the display
value for us without us having to worry about formatting? Automation
is not really an option for various reasons that I won't go into here.
-Sam
I'm currently having an issue dealing with number/date formatting in
Excel. I have a C# winforms application which uses a third party
component (GemBox) to open and read Excel files without having to
instantiate Excel.
The problem I'm running into is that from this control, when I look at
a cell containing a date value, I get back a C# DateTime object. If
the value visibile in Excel is "12/1/2000", I get back "12/1/2000
12:00:00 AM" (the date plus the time).
Now, for each cell, there is a property called "NumberFormat" that
gives me the format that Excel is using to display the cell. In the
above date's case, the NumberFormat is "M/D/YY".
Now, the quick hack is to convert "M/D/YY" into "MM/dd/yyyy" and use
string.Format() in C# to display the date as "12/1/2000". However,
from what I have read, the string that Excel can return for its date
format (M/D/YY) can vary from culture to culture, and the app I am
developing must support many different international formats. (For
instance, I have read that in Italy, the date format might come back
as "aa/mm/gggg" or some craziness).
So what I was wondering is:
1. Has anyone ran into this situation before and been able to solve it
2. Does anyone have a table of all the different format strings Excel
uses, so I at least can try to parse them properly?
OR
3. Does anyone know of a third party control that can get the display
value for us without us having to worry about formatting? Automation
is not really an option for various reasons that I won't go into here.
-Sam