ASP.NET 页面中水晶报表导出
2004-11-22 16:44
591 查看
一大段代码,看看吧。
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);
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);
相关文章推荐
- asp.net中发送邮件的几种方式
- ASP.NET控件的设计时支持
- ASP.NET 中 Cookie 的基本知识
- 使用 ASP.NET 的验证控件(转)
- 在 ASP.NET 中使用计时器(Timer)
- Windows 2003下不注册组件用ASP发邮件
- 新的学期开始了。。。
- “Visual Studio.net已检测到指定的Web服务器运行的不是Asp.net1.1版。您将无法运行Asp.net Web应用程序或服务”问题的解决方法
- 常用ASP.NET解决问题
- 摘抄-我学习ASP.NET时的笔记
- 使用 ASP.NET 顯示事件日誌紀錄
- 在asp.net里创建CrystalReportViewer时老是出错,后来在这里查了些资料才搞定要在web.config中设置如下
- ASP.NET发邮件(20041120)
- 维护 ASP 应用程序的安全
- 发布攻击台湾国旗设计网的ASP代码:
- 创建ASP.NET WEB自定义控件——例程2
- 创建ASP.NET WEB自定义控件——例程1
- 如何解决ASP.NET中中文不能正常显示问题?
- [ASP.NET]一个实用的弹出窗口函数
- 基于ASP.NET的自定义分页显示