#region 读取模板
Excel.Application xapp = new Excel.Application();
//导出数据的模板
Excel.Workbook xbook = xapp.Workbooks._Open(context.Server.MapPath("~/Search/template/" + template), Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value);
Excel.Worksheet xsheet = (Excel.Worksheet)xbook.Sheets[1];
#endregion
#region 读取数据
//导出文本
Excel.Range rngD2 = xsheet.get_Range("D2", Missing.Value);
rngD2.Value2 = row["productCode"].ToString();
//...
string imageUrl = context.Server.MapPath("~/admin/" + row["imageUrl"].ToString());
//导出图片
if (System.IO.File.Exists(imageUrl))
{
Excel.R
C#导出数据到Excel——简单数据导出
最新推荐文章于 2023-11-18 20:24:06 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)