自动生成EXCEL
private string GenerateExcel(DataTable noticeTable)
{
try
{
string fileName = $"NotQuoted{DateTime.Now:yyyyMMddHHmmss}";
string filePath = PathUtils.GetPhysicalPath("ProductCenterNotQuoted", fileName) + ".xlsx";
string fileUrl = PathUtils.GetServerPath("ProductCenterNotQuoted", fileName) + ".xlsx";
ExcelOperation helper = new ExcelOperation();
helper.BeginExport();
List<ListHeader> listField = new List<ListHeader>
{
new ListHeader("FORGNAME", new LocaleValue("组织")),
new ListHeader("FMATERIALNUMBER", new LocaleValue("物料编码")),
new ListHeader("FMATERIALNAME", new LocaleValue("物料名称")),
new ListHeader("FSPECIFICATION", new LocaleValue("规格型号")),
new ListHeader("FERPCLSNAME", new LocaleValue("物料属性")),
new ListHeader("FCATEGORYNAME", new LocaleValue("存货类别")),
new ListHeader("FGROUPNAME", new LocaleValue("物料分组"))
};
List<string> columnsNames = listField.Select((ListHeader p) => p.Caption.ToString()).ToList();
helper.ExportToFile(listField, noticeTable);
helper.FillColumnName(columnsNames, 0);
//生成Excel文件
helper.EndExport(filePath, SaveFileType.XLSX);
return fileUrl;
}
catch (Exception ex)
{
Logger.Info("XXXXXX", ex.Message + "\n" + ex.StackTrace);
return "";
}
}
怎么按模板导出啊
自动生成EXCEL
本文2024-09-16 17:25:17发表“云星空知识”栏目。
本文链接:https://wenku.my7c.com/article/kingdee-k3cloud-15591.html