EPPlus的通用Excel生成器功能 [英] Generic Excel Generator function for EPPlus
本文介绍了EPPlus的通用Excel生成器功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何为您的LINQ查询构建通用的EPPlus电子表格功能?
How would one build a generic EPPlus Spreadsheet function for your LINQ Queries?
更新:专门针对ASP.NET MVC应用程序.
UPDATE: The need was specifically for an ASP.NET MVC application.
推荐答案
现在有了使用LoadFromCollection方法实现此目的的更简单方法.
There is now a more simple way to achieve this using the LoadFromCollection method.
public void ExportToExcel(IEnumerable<Employee> employees, FileInfo targetFile)
{
using (var excelFile = new ExcelPackage(targetFile))
{
var worksheet = excelFile.Workbook.Worksheets.Add("Sheet1");
worksheet.Cells["A1"].LoadFromCollection(Collection: employees, PrintHeaders: true);
excelFile.Save();
}
}
从此处获取的示例: http://gruffcode .com/2013/10/30/simple-excel-export-with-epplus/
这篇关于EPPlus的通用Excel生成器功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文