Format DateTimeValue

Technical support for Spire.XLS

Moderators: iceblue support, Flash, Manager

Format DateTimeValue

Postby lameb » Wed Oct 24, 2012 8:19 am

Hallo,

i give a datetimevalue in US format to Excel without formatting.
The current Culture is in our program en-US.
My computer system region and language is German.
Now in Excel is the displayed format of the cell M.T.JJJJ .

Change I my computer settings to English US - it works fine.

How is it possible to show the correct date format without
specially set the RangeNumberFormat?

Thanking you in anticipation
lameb
 
Posts: 10
Joined: Mon Feb 20, 2012 2:39 pm

Re: Format DateTimeValue

Postby amy.zhao » Thu Oct 25, 2012 2:57 am

Hi lameb,

Thanks for your inquiry.
You only need to set datetime format to US format in your program, we provide you sample code. If you have any problem, please feel free to contact us.
Code: Select all
            Worksheet sheet = workbook.Worksheets[0];
            sheet.Range["A1"].Text = "Date";
            sheet.Range["B1"].DateTimeValue = System.DateTime.Today;
            sheet.Range["B1"].Style.NumberFormat = "mm-dd-yyyy"; // set US datetime format

Best regards,
Amy
E-iceblue support
User avatar
amy.zhao
 
Posts: 2277
Joined: Wed Jun 27, 2012 8:50 am

Re: Format DateTimeValue

Postby lameb » Thu Oct 25, 2012 2:28 pm

I know, that i can set the numberformat.
During our program runs, it is possible to change the language
and the display format for the program. This language does not have to
the same as the settings of the computer.
So, i want set the numberformat one times (standard US or UK)
and according as what regions settings run on the computer,
it shows in Excel correctly.
How is that possible?
lameb
 
Posts: 10
Joined: Mon Feb 20, 2012 2:39 pm

Re: Format DateTimeValue

Postby amy.zhao » Fri Oct 26, 2012 9:49 am

Hi lameb,

Spire.xls will set a default format (yyyy-M-d) for date automaticly If don't set datatime format and only write date value, so spire.xls don't support the fearture setting the numberformat according as what regions settings run on the computer at present, we are sorry for that. We maybe support the featrue in the future, once we have supported it, we will inform you immediately.

Best regards,
Amy
E-iceblue support
User avatar
amy.zhao
 
Posts: 2277
Joined: Wed Jun 27, 2012 8:50 am


Return to Spire.XLS

Who is online

Users browsing this forum: No registered users and 0 guests