下面介绍两种将Spread文件以Excel格式保存到客户端的方法:
方法一:使用Response流的方式将Spread文件以excel格式导出到客户端- protected void Button1_Click(object sender, EventArgs e)
- {
- //使用Response流的方式将Spread文件以excel格式导出到客户端
- System.IO.MemoryStream ms = new System.IO.MemoryStream();
- FpSpread1.SaveExcel(ms, FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);
- Response.Clear();
- Response.ContentType = "application/VND.ms-excel";
- Response.AddHeader("Content-Disposition", "attachment;filename=test1.xls");
- Response.BinaryWrite(ms.ToArray());
- ms.Flush();
- ms.Close();
- Response.End();
- }
复制代码 方法二:使用Spread提供的SaveExcelToResponse方法,将Spread文件以excel格式导出到客户端- protected void Button2_Click(object sender, EventArgs e)
- {
- //使用Spread提供的SaveExcelToResponse方法将Spread文件以excel格式导出到客户端
- FpSpread1.SaveExcelToResponse("test2.xls", FarPoint.Excel.ExcelSaveFlags.SaveCustomColumnHeaders);
- }
复制代码
Spread_Web_Demo.zip
(3.87 MB, 下载次数: 833)
|
|