你的理解是对的,下面是完整的方法代码:
/// <summary>
/// 导出数据
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btn_Export_Click(object sender, EventArgs e)
{
System.IO.MemoryStream s = new System.IO.MemoryStream();
fp_ProjectPlanIndex.SaveExcel(s, FarPoint.Excel.ExcelSaveFlags.NoFlagsSet);
s.Position = 0;
FarPoint.Web.Spread.FpSpread fp = new FarPoint.Web.Spread.FpSpread();
//fp.Sheets.Count = 5;
FarPoint.Web.Spread.SheetView svProject = new SheetView();
svProject.SheetName = "项目规划指标";
fp.Sheets.Add(svProject);
svProject.OpenExcel(s, 0);
s.Close();
s = new System.IO.MemoryStream();
fp_ResidencePlanIndex.SaveExcel(s, FarPoint.Excel.ExcelSaveFlags.NoFlagsSet);
s.Position = 0;
FarPoint.Web.Spread.SheetView svProduct = new SheetView();
svProduct.SheetName = "产品规划指标";
fp.Sheets.Add(svProduct);
svProduct.OpenExcel(s, 0);
s.Close();
fp.ActiveSheetView.Protect = false; //设置导出来之后是否只读
string fileName = Server.UrlEncode("历史规划信息" + DateTime.Now.ToString("yyyyMMdd") + ".xls");
fp.SaveExcelToResponse(fileName, FarPoint.Excel.ExcelSaveFlags.NoFlagsSet);
} |