0

I am outputting a timespan of value 00:25 into an excel sheet using the following:

string.Format("{0}:{1}",
Convert.ToInt32(Math.Truncate(shift.MealBreak.TotalHours)).ToString("D2"),
shift.MealBreak.Minutes.ToString("D2"));

Bit overkill but does the job.

However when put into excel all the other values of like 09:00 done using the same format come out at 09:00 but the above scenario appears as 00:25:00 when the final excel sheet is downloaded.

Is there a way to force ClosedXML to not re-format 00:25 to 00:25:00?

I have looked around and really failed to really find anything yet on the topic, I could be blind though.

Waqar Ahmed
  • 1,414
  • 2
  • 15
  • 35
Mike
  • 618
  • 2
  • 8
  • 27
  • 1
    The only way with excel is to make the timespan a string. Change format of cell the text or add a single quote in front of string. – jdweng Oct 30 '15 at 12:56
  • @jdweng The single quote worked, can put it as an actual answer if you like and I'll mark it – Mike Oct 30 '15 at 13:18

1 Answers1

1

The only way with excel is to make the timespan a string. Change format of cell the text or add a single quote in front of string.

jdweng
  • 33,250
  • 2
  • 15
  • 20