Because I previously mentioned the issue of not supporting the long type being set as text,this.
So I changed my mind and went through the formatted template to upgrade to a file, but I found that the formatting set by miniexcel configuration did not work, including other configurations did not work, and I wanted to know what the problem was.
var tmplatePath = Path.Combine("C:\\Demo\\", $"template.xlsx");
var path = Path.Combine("C:\\Demo\\", $"{Guid.NewGuid()}.xlsx");
var data = new[]
{
new
{
Num= 50.5,
BaiFen= 0.5,
LongText = "1550432695793487872",
DateField = new DateTime(2025,6,17),
TextField = "ABC123"
}
};
var config = new OpenXmlConfiguration
{
AutoFilter = false,
EnableAutoWidth=true,
FastMode=true,
DynamicColumns = new[]
{
new DynamicExcelColumn("Num") { Format = "0.00"},
new DynamicExcelColumn("BaiFen") { Format = "0.00%"},
new DynamicExcelColumn("DateField"){ Format = "yyyy-mm-dd"},
new DynamicExcelColumn("TextField"){ Format = "@" }
}
};
//MiniExcel.SaveAs(path, data , configuration: config);
MiniExcel.SaveAsByTemplate(path, tmplatePath, new { items = data }, configuration: config);
Excel Type
Upload Excel File
template.xlsx
MiniExcel Version
1.41.2
Description
Because I previously mentioned the issue of not supporting the long type being set as text,this.
So I changed my mind and went through the formatted template to upgrade to a file, but I found that the formatting set by miniexcel configuration did not work, including other configurations did not work, and I wanted to know what the problem was.