日期:2014-05-16 浏览次数:20415 次
public void GetURL(Reprots reprotsInfo)
{
if (Session["FileName"] != null)
{
string oldfileName = Session["FileName"].ToString();
string oldxlsPath = Server.MapPath("~/DownLoad/" + oldfileName);
//保存Excel单网页格式的文件路径
string oldhtmlPath = oldxlsPath.Replace(".xls", ".mht");
FilePicDelete(oldhtmlPath);
FilePicDelete(oldxlsPath);
}
SpreadsheetGear.IWorkbookSet workbookSet = SpreadsheetGear.Factory.GetWorkbookSet(System.Globalization.CultureInfo.CurrentCulture);
SpreadsheetGear.IWorkbook workbook = workbookSet.Workbooks.OpenFromMemory(reprotsInfo.ReportContent);
SpreadsheetGear.IWorksheet worksheet = workbook.Worksheets[0];
//向Excel中添加单元格和图形的填充数据
GetConfigData(workbook, reprotsInfo.ReportID);
//把当前的Excel转为二进制
Byte[] reportContent = workbook.SaveToMemory(SpreadsheetGear.FileFormat.Excel8);
//保存文件名
string fileName = Session["Account"].ToString() + reprotsInfo.ReportName + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls";
Session["FileName"] = Session["Account"].ToString() + reprotsInfo.ReportName + DateTime.Now.ToString("yyyyMMddhhmmss") + ".xls"; ;
//保存Excel文件路径
string xlsPath = Server.MapPath("~/DownLoad/" + fileName);
//保存Excel单网页格式的文件路径
string htmlPath = xlsPath.Replace(".xls", ".mht");
//设置当前的Excel的保存路径
FileStream fs = new FileStream(xlsPath, FileMode.Create);
//保存当前Excel文件