Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

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

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: 2766
Joined: Wed Jun 27, 2012 8:50 am

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

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: 2766
Joined: Wed Jun 27, 2012 8:50 am

Return to Spire.XLS