#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.Range rngA11 = xsheet.get_Range("A11", Missing.Value);
Excel.
C#导出数据到Excel——简单数据导出
最新推荐文章于 2024-06-17 23:31:56 发布
