ASP.NET 页面中水晶报表导出
string sDestFile = Path.GetTempFileName();
string sExportFormatType = text_export.SelectedItem.Text;
if (sExportFormatType == "")
return;
DiskFileDestinationOptions diskOpts = new DiskFileDestinationOptions();
diskOpts.DiskFileName = sDestFile;
oRpt.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile;
switch (sExportFormatType)
{
case "Mircrosoft Word 文档":
{
oRpt.ExportOptions.ExportFormatType = ExportFormatType.WordForWindows;
break;
}
case "Mircrosoft Excel 文档":
{
oRpt.ExportOptions.ExportFormatType = ExportFormatType.Excel;
break;
}
case "Adobe PDF 文档":
{
oRpt.ExportOptions.ExportFormatType = ExportFormatType.PortableDocFormat;
break;
}
}
oRpt.ExportOptions.DestinationOptions = diskOpts;
oRpt.Export();
Response.ClearContent();
Response.ClearHeaders();
switch (sExportFormatType)
{
case "Mircrosoft Word 文档":
{
Response.ContentType = "application/msword";
break;
}
case "Mircrosoft Excel 文档":
{
Response.ContentType = "application/vnd.ms-excel";
break;
}
case "Adobe PDF 文档":
{
Response.ContentType = "application/pdf";
break;
}
}
Response.WriteFile(sDestFile);
Response.Flush();
Response.Close();
File.Delete(sDestFile);