dotnetcore / dotnetcore/Magicodes.IE

Datatable动态导出Excel,IExporterHeaderFilter设置禁用表头筛选器无效

Open
#566 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
2.2k
Forks
495
PR merge metrics
No merged PRs in 30d

Description

DataTable dt = new DataTable();
dt.Columns.Add(new DataColumn("ProductCode", typeof(string)));
dt.Columns.Add(new DataColumn("ProductName", typeof(string)));
dt.Columns.Add(new DataColumn("Quantity", typeof(string)));
for (int i = 0; i < 10; i++)
{
var row = dt.NewRow();
row["ProductCode"] = "ProductCode" + i.ToString();
row["ProductName"] = "ProductName" + i.ToString();
row["Quantity"] = "Quantity" + i.ToString();
dt.Rows.Add(row);
}
IExcelExporter excelExporter = new ExcelExporter();
//设置IExporterHeaderFilter为null无效
var res = await excelExporter.ExportAsByteArray(dt,null);
return new FileStreamResult(new MemoryStream(res), "application/octet-stream")
{
FileDownloadName = $"{DateTime.Now.ToString("yyyyMMdd")}.xlsx"
};

还是有筛选器
![17188696021728](https://github.com/dotnetcore/Magicodes.IE/assets/14521170/20081b91-3946-4ce8-8f6d-8ea997adcf27)

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.