最新97ai蜜桃,梵林伽晴天团队娟子,guodexiu
npoi完整代码:net npoi帮助类
public static void datatabletoexcel(list<datatable> datatables, string filepath) { if (datatables == null || !datatables.any()) throw new exception("datatables不能为null"); bool isoldthan2007 = path.getextension(filepath)?.tolower() == ".xls"; iworkbook book = datatables.toworkbook(isoldthan2007); using (filestream fs = new filestream(filepath, filemode.create, fileaccess.write)) { book.write(fs); } }
public static iworkbook toworkbook(this list<datatable> datatables, bool isoldthan2007) { iworkbook book = isoldthan2007 ? new hssfworkbook() : (iworkbook)new xssfworkbook(); foreach (var datatable in datatables) { if (datatable == null) continue; isheet sheet = book.createsheet(datatable.tablename); irow headerrow = sheet.createrow(0); foreach (datacolumn column in datatable.columns) { headerrow.createcell(column.ordinal).setcellvalue(column.columnname); } for (int i = 0; i < datatable.rows.count; i++) { datarow row = datatable.rows[i]; irow datarow = sheet.createrow(i + 1); for (int j = 0; j < datatable.columns.count; j++) { datarow.createcell(j).setcellvalue(row[j]?.tostring()); } } } return book; }
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Net Core Web Api项目与在NginX下发布的方法
asp.net core3.1 引用的元包dll版本兼容性问题解决方案
IdentityServer4实现.Net Core API接口权限认证(快速入门)
ASP.NET Core MVC通过IViewLocationExpander扩展视图搜索路径的实现
网友评论