CSDN首页 空间 新闻 论坛 Blog 下载 读书 网摘 搜索 .NET Java 视频 接项目 求职 在线学习 买书 程序员 通知
山寨机中的战斗机! 程序优化工程师到底对IT界有没有贡献
CSDN社区
搜索 收藏 打印 关闭
CSDN社区 >  .NET技术 >  图表区

水晶报表的导出问题

楼主agandotnet()2006-06-01 15:40:05 在 .NET技术 / 图表区 提问

怎么将水晶报表导出成pdf,xsl,doc等格式的文件,我指的是在web下,用c# 问题点数:5、回复次数:3Top

1 楼ami_glacier(ami冰河)回复于 2006-06-17 17:16:30 得分 0

public   static   void   ShowPDF(HttpResponse   reponse,   string   DestFile)  
  {  
  reponse.ClearContent();  
  reponse.ClearHeaders();    
  reponse.ContentType   =   "application/pdf";  
  reponse.WriteFile(DestFile);  
  reponse.Flush();  
  reponse.Close();    
  }  
   
  public   static   void   ExportPDF(ReportDocument   myreport,string   DestFile)  
  {  
  CrystalDecisions.Shared.DiskFileDestinationOptions   diskOpts   =   new   CrystalDecisions.Shared.DiskFileDestinationOptions();  
  diskOpts.DiskFileName   =   DestFile;    
  myreport.ExportOptions.ExportDestinationType   =   CrystalDecisions.Shared.ExportDestinationType.DiskFile;  
  myreport.ExportOptions.ExportFormatType   =   CrystalDecisions.Shared.ExportFormatType.PortableDocFormat;  
  myreport.ExportOptions.DestinationOptions   =   diskOpts;  
  myreport.Export();  
  }  
   
  这个是打开和导出pdf的代码,其他的你可以找找海波的blog区看看Top

2 楼llbasin()回复于 2006-06-27 10:17:58 得分 0

private   CrystalReportForPj   cr   =   new   CrystalReportForPj();  
  private   ReportDocument     rd;  
   
  private   void   Page_Load(object   sender,   System.EventArgs   e)  
  {  
      rd=new   ReportDocument();  
      rd.Load(Server.MapPath("CrystalReportForPj.rpt"));  
  }  
   
  private   void   export_Click(object   sender,   System.EventArgs   e)  
  {  
   
  string   sDestFile   =   Path.GetTempFileName();  
                           
  string   sExportFormatType   =   text_export.SelectedItem.Text;  
   
  if   (sExportFormatType   ==   "")  
  return;    
   
  DiskFileDestinationOptions   diskOpts   =   new   DiskFileDestinationOptions();  
  diskOpts.DiskFileName   =   sDestFile;    
  rd=cr;//这句不可少  
   
  switch   (sExportFormatType)  
  {  
  case   "Mircrosoft   Word   文档":  
  {  
  rd.ExportOptions.ExportFormatType   =   ExportFormatType.WordForWindows;  
  break;  
  }  
  case   "Mircrosoft   Excel   文档":  
  {  
  rd.ExportOptions.ExportFormatType   =   ExportFormatType.Excel;  
  break;  
  }  
  case   "Adobe   PDF   文档":  
  {  
  rd.ExportOptions.ExportFormatType   =   ExportFormatType.PortableDocFormat;  
  break;  
  }  
  }    
   
   
  rd.ExportOptions.ExportDestinationType   =   ExportDestinationType.DiskFile;  
  rd.ExportOptions.DestinationOptions   =   diskOpts;  
   
  rd.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);  
  }  
   
  另外需将aspnet用户设置为administrator权限.Top

3 楼foxflying(会飞的鱼)回复于 2006-07-06 13:41:55 得分 0

private   CrystalReportForPj   cr   =   new   CrystalReportForPj();  
  我在2005下,这一行语句就提示错了,找不到对象,似乎是名称空间的问题。可是没有办法看到报表的cs文件,我怎么定义这个呢?  
   
  直接用rd=new   ReportDocument();  
      rd.Load(Server.MapPath("CrystalReportForPj.rpt"));  
  导出到新页面的时候,页面是空白的,没有显示报表。  
   
  请问该怎么解决?Top

相关问题

关键词

得分解答快速导航

  • 帖主:agandotnet

相关链接

  • CSDN .NET频道
  • .NET类图书
  • C#类图书
  • .NET类源码下载

广告也精彩

反馈

请通过下述方式给我们反馈
反馈
提问
网站简介|广告服务|VIP资费标准|银行汇款帐号|网站地图|帮助|联系方式|诚聘英才|English|问题报告
北京创新乐知广告有限公司 版权所有, 京 ICP 证 070598 号
世纪乐知(北京)网络技术有限公司 提供技术支持
Copyright © 2000-2008, CSDN.NET, All Rights Reserved
GongshangLogo