如何在导出的excel中加入分页符
我的导出代码是这样的。
public static void GetDataFile(Table table)
{
//文件名为当前日期+4位随机数
string strFileName = DateTime.Today.ToString("yyyyMMdd") + new Random(DateTime.Now.Millisecond).Next(10000).ToString() + ".xls";
HttpContext.Current.Response.Clear();
HttpContext.Current.Response.Buffer = true;
HttpContext.Current.Response.Charset = "Default";
HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=" + strFileName);
HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.GetEncoding("IBM437");//设置输出流为美国英语
HttpContext.Current.Response.ContentType = "application/ms-excel";//设置输出文件类型为excel文件。
System.Globalization.CultureInfo ciExcel = new System.Globalization.CultureInfo("en-US", true);
StringWriter swExcel = new StringWriter(ciExcel);
System.Web.UI.HtmlTextWriter htwExcel = new System.Web.UI.HtmlTextWriter(swExcel);
table.RenderControl(htwExcel);
HttpContext.Current.Response.Write(swExcel.ToString());
HttpContext.Current.Response.End();
}
希望导出的文件里就已经在指定的地方加上分页符了。