Date- but no time OR time- but no date


#1

I am exporting some DateTime values into excel with your component. What I would like to do is have the values come into the spreadsheet in the following manner.

Say, for example, the DateTime value from .NET is "08/09/2004 01:30 PM".

I want this to come into Excel with the date in column A and the time in column B.

I am able to do this however, when I click on the resulting cell in Excel, even though the formatting is correct, the DateTime value appears in the Formula Bar edit window.

I know if I just use excel, I can type in a time or type in a date and just have that be the value. Is there a way to to this by exporting data with your component?

Here is my code...

Aspose.Excel.Excel excel = new Excel();
Worksheet sheet = excel.Worksheets[0];

int index = excel.Styles.Add();
Aspose.Excel.Style dateStyle = excel.Styles[index];
index = excel.Styles.Add();
Aspose.Excel.Style timeStyle = excel.Styles[index];

dateStyle.Number = 14;
timeStyle.Number = 18;

sheet.Cells[0, 0].PutValue(DateTime.Now);
sheet.Cells[0, 0].Style = dateStyle;

sheet.Cells[0, 1].PutValue(DateTime.Now);
sheet.Cells[0, 1].Style = timeStyle;

string path = Server.MapPath("~\\clients\\" + ((PageBase)this.Page).CurrentLogin.Client.DataFilesFolder + "\\export\\");
excel.Save(path + "schedule.xls", FileFormatType.Excel97);


#2

Figured out the issue here.

If outputting only a date, the time value on the DateTime must be “12:00 AM”.

If outputting only a time, the time value on the DateTime must be “12/31/1899”.

I determined this by creating a spreadsheet in the format I was speaking of and opened it with your control. I then examined the values of the cells which revealed what the underlying values in Excel were.