Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/string/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# ClosedXML时间跨度格式_C#_Closedxml - Fatal编程技术网

C# ClosedXML时间跨度格式

C# ClosedXML时间跨度格式,c#,closedxml,C#,Closedxml,我正在使用以下命令将值为00:25的时间跨度输出到excel工作表中: string.Format("{0}:{1}", Convert.ToInt32(Math.Truncate(shift.MealBreak.TotalHours)).ToString("D2"), shift.MealBreak.Minutes.ToString("D2")); 有点过火了,但能起作用 然而,当放入excel时,使用相同格式完成的所有其他值(如09:00)将在09:00出现,但在下载最终excel工作表时

我正在使用以下命令将值为00:25的时间跨度输出到excel工作表中:

string.Format("{0}:{1}",
Convert.ToInt32(Math.Truncate(shift.MealBreak.TotalHours)).ToString("D2"),
shift.MealBreak.Minutes.ToString("D2"));
有点过火了,但能起作用

然而,当放入excel时,使用相同格式完成的所有其他值(如09:00)将在09:00出现,但在下载最终excel工作表时,上述场景显示为00:25:00

有没有办法强制ClosedXML不重新格式化00:25到00:25:00


我环顾四周,确实没有找到关于这个主题的任何东西,但我可能是瞎子。

使用excel的唯一方法是将时间跨度设置为字符串。更改单元格文本的格式或在字符串前面添加一个引号。

使用excel的唯一方法是将时间跨度设置为字符串。更改单元格文本的格式或在字符串前添加一个引号。@jdweng如果单引号有效,可以将其作为实际答案,我会标记它