I need my excel output to have a column with time in HH: mm format.
My code is as follows:
ws.Cells[rowNumber, 11].Style.Numberformat.Format = "hh:mm"; string start = row.R_HourStart.ToString("HH:mm:ss"); ws.Cells[rowNumber, 11].Value = start;
But when I open the file in excel, the cell displays "10:10:00".
When I paste the text into the formula bar and press the enter button, the cell text changes to "10:10", which is what I want.
I also tried using:
ws.Cells[rowNumber, 11].Style.Numberformat.Format = "hh:mm"; string start = row.R_HourStart.ToString("HH:mm:ss"); ws.Cells[rowNumber, 11].LoadFromText(start);
I get "10:10" in the cell, but today the formula bar displays the full date today with the hour 10:10.
In addition, I tried:
ws.Cells[rowNumber, 12].Style.Numberformat.Format = "hh:mm"; ws.Cells[rowNumber, 12].Value = row.R_HourEnd;
Which shows "10:10" in the cell, but the formula bar displays the entire date and time as "08/22/2014 10:10:00".
source share