如何导出带有两位小数的 kendo 网格(有文化)

How to export the kendo grid with two decimal places (with culture)

我有一个网格,我的数据包含数字 属性 值的小数点后 3 位。我想导出网格,但仍然有 2 位的小数格式。但它没有发生。它在网格中显示 2 位小数,但当我单击导出时,它在 excel 文件中变为 3 位小数。我之所以使用“{0:N2}”),是因为当我使用其他文化时,它会相应地显示。 最好的方法是什么?

@(Html.Kendo().Grid<Box>()
        .Name("gridKendo")
        .Columns(columns =>
        {
            columns.Bound(l => l.Name).Locked(true);
            columns.Bound(l => l.Length).Format("{0:N2}");
            columns.Bound(l => l.Length2).Format("{0:N2}");
            columns.Bound(l => l.Length3).Format("{0:N2}");
        })
        .ToolBar(toolBar =>
        {
            toolBar.Create().Text("Add Book");
            toolBar.Excel();
        })
        .Editable(editable => editable.Mode(GridEditMode.InLine))
        .Pageable(pageable => pageable
            .Refresh(true)
            .PageSizes(true)
            .ButtonCount(5))
        .Sortable(sortable => sortable
            .AllowUnsort(true)
            .SortMode(GridSortMode.MultipleColumn))
        .Filterable()
        .Groupable()
        .Excel(excel => excel
            .FileName("Excel.xlsx")
            .Filterable(true)
            .ProxyURL(Url.Action("ExportToExcel", "Grid")) 
        )
        .DataSource(dataSource => dataSource
            .WebApi()
            .PageSize(10)

来自 Kendo UI 的 Excel Export & Column Formats 文档:

Kendo UI Grid doesn't use column formats during Excel export because some Kendo UI formats are incompatible with Excel.

To format the cell values set the format option of the cells.

The Create a custom number format page describes the formats that Excel supports.

The Cell Format tutorial shows how to format the cell values.