Ho can set date and time value in excel by excel automation?
-
Hi all, i m using excel automation to write excel file. everything is working fine but when i insert date and time value in excel sheet it not displayed in proper format. i m inserting date and time value in this format "Dec 16, 2010 06:17:00 PM" but it display in this format "16/12/2010 6:17:00 PM" and also if date and column width is small it display only # here. please tell me how can i insert the date and time value to show in same format in excel file. thanks in advance.
-
Hi all, i m using excel automation to write excel file. everything is working fine but when i insert date and time value in excel sheet it not displayed in proper format. i m inserting date and time value in this format "Dec 16, 2010 06:17:00 PM" but it display in this format "16/12/2010 6:17:00 PM" and also if date and column width is small it display only # here. please tell me how can i insert the date and time value to show in same format in excel file. thanks in advance.
You need to set the format for the column to display the time in the way you want, and the width of the column to display all its content. The # string merely indicates that the column is not wide enough for Excel to display its content.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
You need to set the format for the column to display the time in the way you want, and the width of the column to display all its content. The # string merely indicates that the column is not wide enough for Excel to display its content.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
Le@rner wrote:
please tell me how can i do this?
Check the options for cell properties in the documentation; I suspect that the actual details may vary depending on which version of Excel you are using.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
Richard MacCutchan wrote:
You need to set the format for the column to display the time in the way you want
please tell me how can i do this?
Le@rner wrote:
please tell me how can i do this?
Check the options for cell properties in the documentation; I suspect that the actual details may vary depending on which version of Excel you are using.
Just say 'NO' to evaluated arguments for diadic functions! Ash
-
Hi all, i m using excel automation to write excel file. everything is working fine but when i insert date and time value in excel sheet it not displayed in proper format. i m inserting date and time value in this format "Dec 16, 2010 06:17:00 PM" but it display in this format "16/12/2010 6:17:00 PM" and also if date and column width is small it display only # here. please tell me how can i insert the date and time value to show in same format in excel file. thanks in advance.
Hi, with this Excel .NET component you can easily do this: Here is a sample Excel C# code (managed C++/CLI shouldn't be much different):
var ef = new ExcelFile();
var cell = ef.Worksheets.Add("Sheet 1").Cells[0, 0];
cell.Value = new DateTime(2010, 12, 16, 18, 17, 00);
cell.Style.NumberFormat = "mmm dd, yyyy hh:mm:ss AM/PM";ef.SaveXls(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), "DateTime.xls"));