导出Excel 第一行指定位置导出自定义标题
用下面方法导出Excel,现在导出的第一行为列名,第二行以下为数据...
怎么使用第一行为自定义标题呢?(例如:导出显示第一行的A1~A10单元格合并为:制造部数据)
网上查了下 说用NPOI http://www.zlblogs.com/export-excel-merge-cells.html 有点复杂!
能否简单的方法 实现 第一行指定位置加入标题!
谢谢 大家指点!!
public void DataSetToExcel(DataTable dt) { HttpResponse resp = HttpContext.Current.Response; resp.Clear(); resp.AppendHeader("Content-Disposition", "attachment;filename=\"" + HttpUtility.UrlEncode("application / vnd.ms - excel", System.Text.Encoding.UTF8) + "\""); resp.ContentType = "application/ms-excel;"; //resp.ContentEncoding = Encoding.GetEncoding("GB2312"); resp.ContentType = "application/vnd.ms-excel"; resp.AppendHeader("Content-Disposition", "attachment;filename=Excel.cvs"); StringWriter oSW = new StringWriter(); HtmlTextWriter oHW = new HtmlTextWriter(oSW); DataGrid dg = new DataGrid(); dg.DataSource = dt; dg.DataBind(); dg.RenderControl(oHW); resp.Write(oSW.ToString()); resp.Flush(); resp.Close(); }