Asp.net mvc TimeSpan数据类型在导出到Excel时未获取正确的时间

Asp.net mvc TimeSpan数据类型在导出到Excel时未获取正确的时间,asp.net-mvc,kendo-ui,kendo-grid,kendo-asp.net-mvc,Asp.net Mvc,Kendo Ui,Kendo Grid,Kendo Asp.net Mvc,我创建了一个小项目,在其中我使用TimeSpan数据类型,并尝试获取登录和注销时间,但在导出到excel时,时间不会显示在excel列中 请帮帮我 这是我使用timespan的代码: public TimeSpan PunchIn { get; set; } [NotMapped] public string Month { get { var In = TimeZoneInfo.ConvertTimeFromUtc(PunchDate.Date + Punch

我创建了一个小项目,在其中我使用TimeSpan数据类型,并尝试获取登录和注销时间,但在导出到excel时,时间不会显示在excel列中

请帮帮我

这是我使用timespan的代码:

public TimeSpan PunchIn { get; set; }

[NotMapped]
public string Month
{
    get
    {
        var In = TimeZoneInfo.ConvertTimeFromUtc(PunchDate.Date + PunchIn,
            TimeZoneInfo.FindSystemTimeZoneById(User.RegisteredTimeZone));
        return In.ToString("MMMM");
    }
}
这是剑道网格代码:

@(Html.Kendo().Grid(Model)
      .Name("TimeTrackingLogsGrid")
      .Columns(columns =>
      {
          columns.Bound(c => c.Id).Hidden(true).HtmlAttributes(new {style="text-align:center;"});
          columns.Bound(c => c.IsDeleted).Hidden(true);
          columns.Bound(c => c.ApprovalRequired).Visible((bool)ViewBag.IsAdmin).ClientTemplate("# if (ApprovalRequired == true && Approved == false && '"+ (ViewBag.IsAdmin).ToString() + "'=== 'True') {# Yes: <a data-ajax='true' data-ajax-complete='refreshGrid' data-ajax-method='POST' href='/Punch/Approve/#:Id#' class='grid-link' >Approve</a>#} else{# No #}#");
          columns.Bound(c => c.EmployeeName).Filterable(ftb => ftb.Multi(true).Search(true));
          columns.Bound(c => c.Month).Hidden(true).Filterable(ftb => ftb.Multi(true));
          columns.Bound(c => c.PunchDate)
              .ClientFooterTemplate("#= getFormattdDate(data.PunchDate.min) # - #= getFormattdDate(data.PunchDate.max) # ")
              .ClientGroupHeaderTemplate("#:convetUtcDateToLocalDate(PunchDate)#").HtmlAttributes(new { @class = "utc-date", utc_date_value = "#:PunchDate#" });
          columns.Bound(c => c.PunchInPic).Hidden(true).Visible((bool)ViewBag.IsAdmin).ClientTemplate("<img class='punchPic' width='100' src='data: image / png; base64,#:PunchInPic#'/>").HtmlAttributes(new { style="text-align:center;"});
          columns.Bound(c => c.PunchIn).Groupable(false).Filterable(false).ClientTemplate("#:PunchIn.Hours#:#:PunchIn.Minutes#").HtmlAttributes(new { @class = "utc-time", utc_time_value = "#:PunchIn.Hours#:#:PunchIn.Minutes#" });
          columns.Bound(c => c.PunchOutPic).Hidden(true).Visible((bool)ViewBag.IsAdmin).ClientTemplate("<img class='punchPic' width='100' src='data: image / png; base64,#:PunchOutPic#'/>").HtmlAttributes(new { style = "text-align:center;" });
          columns.Bound(c => c.PunchOut).Groupable(false).Filterable(false).ClientTemplate("#:PunchOut == null ? 0 :PunchOut.Hours #:#: PunchOut == null ? 0 : PunchOut.Minutes  #").HtmlAttributes(new {@class= "utc-time", utc_time_value = "#: PunchOut == null ? 0 : PunchOut.Hours#:#:PunchOut == null ? 0 : PunchOut.Minutes #" });
          columns.Bound(c => c.Duration).Groupable(false).Filterable(false)
              .ClientFooterTemplate("#= SecondsToTime(data.DurationInSeconds.sum) # ")
              .ClientTemplate("#:formatDuration(Duration.Hours,Duration.Minutes) #").HtmlAttributes(new { @class = "" });
          columns.Bound(c => c.Comments).Visible((bool)ViewBag.IsAdmin).Filterable(false).Groupable(false).ClientTemplate("# if (ApprovalRequired == true && Approved == false && '" + (ViewBag.IsAdmin).ToString() + "' !== 'True') {# Please get this time log approved #} else{#<span class='comments' (#:Comments# == null ? '' : title='<ul>  #:Comments# </ul>')> view <span>#}#");
          columns.Command(command =>
          {
              //    command.Edit().Text(" ");
              command.Destroy().Text(" ");
          }).Width(50);
      })
      .HtmlAttributes(new { @class = "full-screen-dashboard" })
      //.Scrollable()
      .Groupable()
      .Sortable()
      .Filterable()
      .Navigatable()
      .ColumnMenu()
      .ToolBar(toolbar => {
          //toolbar.Create();
          //toolbar.Save();
          toolbar.Pdf();
          toolbar.Excel();
          toolbar.Custom().Text("Clear Filter").HtmlAttributes(new { @class= "clearGridFilter"  });
      })

      .Excel(exl=>exl.AllPages(true).Filterable(true).FileName("Timesheet.xlsx")
          .ProxyURL(Url.Action("ExportSave", "Punch")))
@(Html.Kendo().Grid(模型)
.Name(“TimeTrackingLogsGrid”)
.列(列=>
{
columns.Bound(c=>c.Id).Hidden(true).HtmlAttributes(新的{style=“text align:center;”);
columns.Bound(c=>c.IsDeleted).Hidden(true);
columns.Bound(c=>c.ApprovalRequired).Visible((bool)ViewBag.IsAdmin).ClientTemplate(#if(ApprovalRequired==true&&Approved==false&&&')+(ViewBag.IsAdmin.ToString()+“=='true'){#是:#}其他{#否}};
columns.Bound(c=>c.EmployeeName).Filterable(ftb=>ftb.Multi(true).Search(true));
columns.Bound(c=>c.Month).Hidden(true).Filterable(ftb=>ftb.Multi(true));
columns.Bound(c=>c.PunchDate)
.ClientFooterTemplate(“#=GetFormattDate(data.PunchDate.min)#-#=GetFormattDate(data.PunchDate.max)#”)
.ClientGroupHeaderTemplate(“#:convutcDateToLocalDate(PunchDate)#”).HtmlAttributes(新的{@class=“utc日期”,utc日期值=“#:PunchDate#”);
columns.Bound(c=>c.punchimpic).Hidden(true).Visible((bool)ViewBag.IsAdmin).ClientTemplate(“”).HtmlAttributes(新的{style=“text align:center;”);
columns.Bound(c=>c.PunchIn).Groupable(false).Filterable(false).ClientTemplate(“#:PunchIn.Hours#::#:PunchIn.Minutes#”).HtmlAttributes(新的{@class=“utc time”,utc#u time_value=“#:PunchIn.Hours#:#:PunchIn.Minutes#”);
columns.Bound(c=>c.PunchOutPic).Hidden(true).Visible((bool)ViewBag.IsAdmin).ClientTemplate(“”).HtmlAttributes(新的{style=“text align:center;”);
columns.Bound(c=>c.PunchOut).Groupable(false).Filterable(false).ClientTemplate(“#:PunchOut==null?0:PunchOut.Hours::#:PunchOut==null?0:PunchOut.Minutes#”).HtmlAttributes(新的{@class=“utc时间”,utc#time#value=“#:PunchOut==null?0:PunchOut.Hours:#:PunchOut==null?0:;
columns.Bound(c=>c.Duration).Groupable(false).Filterable(false)
.ClientFooterTemplate(“#=SecondsToTime(data.DurationInSeconds.sum)#”)
.ClientTemplate(“#:formatDuration(Duration.Hours,Duration.Minutes)#”).HtmlAttributes(新的{@class=”“});
columns.Bound(c=>c.Comments).Visible((bool)ViewBag.IsAdmin).Filterable(false).Groupable(false).ClientTemplate(“#if(ApprovalRequired==true&&Approved==false&&'”+(ViewBag.IsAdmin).ToString()+”!='true'){请获得此时间日志的批准}否则{查看};
columns.Command(Command=>
{
//command.Edit().Text(“”);
command.Destroy().Text(“”);
}).宽度(50);
})
.HtmlAttributes(新的{@class=“全屏仪表板”})
//.Scrollable()
.Groupable()
.Sortable()
.可过滤()
.Navigatable()
.column菜单()
.ToolBar(ToolBar=>{
//toolbar.Create();
//toolbar.Save();
toolbar.Pdf();
toolbar.Excel();
toolbar.Custom().Text(“清除过滤器”).HtmlAttributes(新的{@class=“clearGridFilter”});
})
.Excel(exl=>exl.AllPages(true).Filterable(true).FileName(“Timesheet.xlsx”)
.ProxyURL(Url.Action(“导出保存”、“打孔”))