Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
us12548 opened this issue Jun 20, 2024 · 0 comments

Comments

@us12548
Copy link

us12548 commented Jun 20, 2024

        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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant