LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Excel NumberFormat

Hi,

I'm currently working in France, where Excel would use the "craziness"
"mm/jj/aaaa" to display what you ask for - if you use the dialog-box in Excel
for formatting your data. Nevertheless, in VB, VBA or any other automaton
link, Excel only accepts the "standard English" format. If you display the
date in Excel, there should therefore be no problem using the English format.

Now, you're saying that you want to display the value with C#. In that case
I don't see the problem, since it's already a C# DateTime object: Handle it
as any other date-time object, and the apply (for example) the local Data
format when displaying it (in C++ you simply put myDate.Format() if myDate is
a COleDateTime object).

" wrote:

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


 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel automation through .NET Interop: NumberFormat property looks like NumberFormatLocal martin durtschi Excel Programming 4 May 13th 14 07:39 PM
NumberFormat danpt Excel Discussion (Misc queries) 3 May 20th 09 10:55 PM
VBA NumberFormat Digit Excel Programming 1 January 30th 05 02:30 PM
NumberFormat strings for Excel Cells R. L. Alan Jordan Excel Programming 2 July 26th 03 02:33 AM


All times are GMT +1. The time now is 05:26 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"