Crystal Report: export to html

摘要:Crystal Report: export to html

Export to html or PDF or Excel file:

Private Sub Print(ByVal strRpt As String)
??? Dim reportDoc As New ReportDocument
??? lblDBErrorMessage.Text = ""
??? Dim rpt_ds As DataSet = GetRptDS()
??? If lblDBErrorMessage.Text "" Then
??????? Exit Sub
??? End If
??? reportDoc.Load(Server.MapPath("demorpt.rpt"))
??? reportDoc.SetDataSource(rpt_ds)
??? Select Case strRpt
??? Case "HTML"
??????? Dim htmlformat As New HTMLFormatOptions
??????? reportDoc.ExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
??????? reportDoc.ExportOptions.ExportFormatType = ExportFormatType.HTML40
??????? htmlformat.HTMLBaseFolderName = Server.MapPath("../printemp/")
??????? ‘放在/printemp/之下,它会自动产生demorpt数据夹
??????? ‘和其他的导出不一样要设定htmlformat
??????? htmlformat.HTMLFileName = "demo.htm"
??????? reportDoc.ExportOptions.FormatOptions = htmlformat
??????? reportDoc.Export()
??????? Dim htmurl As String = "../printemp/demorpt/demo.htm"
??????? Response.Redirect(htmurl)
??? Case "PDF"
??????? Dim objFile As New DiskFileDestinationOptions
??????? reportDoc.ExportOptions.DestinationOptions = objFile
??????? objFile.DiskFileName = Server.MapPath("../printemp/demo.pdf")
??????? With reportDoc.ExportOptions
??????????? .ExportDestinationType = ExportDestinationType.DiskFile
??????????? .ExportFormatType = ExportFormatType.PortableDocFormat
??????????? .DestinationOptions = objFile
??????? End With
??????? reportDoc.Export()
??????? Dim xlsurl As String = "../printemp/demo.pdf"
??????? Response.Redirect(xlsurl)
??? Case "Excel"
??????? Dim objFile As New DiskFileDestinationOptions
??????? Dim CrFormatTypeOptions As New ExcelFormatOptions???????????????????????
??????? With CrFormatTypeOptions??????????????????????????????????????
??????????? .ExcelTabHasColumnHeadings = True????????????????????????
??????????? .ExcelAreaType = AreaSectionKind.PageHeader??????????????
??????????? .ExcelUseConstantColumnWidth = False???????????????????
??????? End With???????????????????????????????????????????????????????
??????? reportDoc.ExportOptions.DestinationOptions = objFile
??????? objFile.DiskFileName = Server.MapPath("../printemp/demo.xls")
??????? With reportDoc.ExportOptions
??????????? .ExportDestinationType = ExportDestinationType.DiskFile
??????????? .ExportFormatType = ExportFormatType.Excel
??????????? .DestinationOptions = objFile
??????????? .FormatOptions = CrFormatTypeOptions???????????
??????? End With
??????? reportDoc.Export()
??????? Dim xlsurl As String = "../printemp/demo.xls"
??????? Response.Redirect(xlsurl)
??? End Select
End Sub

?

原文:大专栏  Crystal Report: export to html

原文地址:https://www.cnblogs.com/chinatrump/p/11518141.html

时间: 2024-08-30 14:52:18

Crystal Report: export to html的相关文章

Crystal Report在.net中的两种显示方式

原文:Crystal Report在.net中的两种显示方式 编写人:CC阿爸 2014-7-29 近来在完成深圳一公司的项目,对方对各方面要求相当严格,一不满意就拒绝签收,为了对修正水晶报表显示及导出的一些小问题,无赖之下,仔细了解一下水晶报表的操作方法,逼苦我们这些苦逼的程序,虽说在以前的项目中,也常使用crystal report 来制作报表.并且针对web与winform 都各有不同的地方. 但总的来讲:显示水晶报表目前使用控件对象的有两种显示方式 1.      使用crystalRe

Crystal Report 在 VS 2010 中的使用和发布

原文:Crystal Report 在 VS 2010 中的使用和发布 使用: 打开CrystalReport官网下载页 目前最新版本为13.0.4 选择“SAP Crystal Reports, version for Visual Studio 2010 - Standard”下载安装,会自动在你VS2010的工具栏产生新的一个“报表设计”的选项卡,改选项卡会添加三个控件:CrystalReportViewer, CrystalReportPartsViewer,CrystalReportS

水晶报表 Crystal Report 调用存储过程时出错 找不到表 ,解决方法。

用 CrystalReportViewer1 控件在asp.net的网页上显示报表,如果做报表时调用数据表数据的方式调用是可以成功的,但报表是用存储过程获取数据方式会出现以下错误: 找不到表'RptOpenCheck;1' . 文件 G:\TEMP\FO-OpenCheck {6D191F06-DECF-4A25-88FC-8553E3D435AA}.rpt 内出错: 找不到表. Error: 未将对象引用设置到对象的实例. The table 'RptOpenCheck;1' could no

Visual Studio 2012使用水晶报表Crystal Report

原文:Visual Studio 2012使用水晶报表Crystal Report SAP在 2013年1月14日 released SAP Crystal Reports,developer version for Microsoft Visual Studio - 2012 .你可以从下面链接下载:http://downloads.businessobjects.com/akdlm/cr4vs2010/CRforVS_13_0_5.exe 下载并安装入你的电脑.安装 完毕,可以看到那些曾经熟

Crystal Report 处理当前系统时间

原文:Crystal Report 处理当前系统时间 Changed the print date format to HH/yy/MM/mm/SS/dd  (For Example:2014/01/23 16:30:45= 161430014523) : iif(Hour(CurrentTime)<10,left('0'+totext(Hour(CurrentTime)),2),left(totext(Hour(CurrentTime)),2))+ right(left(totext((Yea

水晶报表(crystal report )中显示CheckBox

1,在crystal report 报表的右边field explorer导航栏里面 新建一个formula field 并命名 2,右键edit刚建好的formula field ,写一个控制checkbox 显示的表达式如下: if {Command.CLAIMANT_SIGNATURE_FLAG} = 'Y' thenchrw(254)elsechrw(168) 如下图操作: 显示完成 水晶报表(crystal report )中显示CheckBox

解决crystal report水晶报表在浏览器提示bobj未定义的错误

网上的中文文章(比如这篇文章)都是写的部署到服务器后出现的问题,同时也指出要把crystal report的aspnet_client文件夹拷贝到对应项目的根目录里,这样就可以正常显示了,但是具体到我本人的情况,还是无法只通过拷贝aspnet_client这个文件夹就可以解决问题.所以在中文搜索无果的情况下,通过英文搜索关键字 bobj is undefined后,最终解决问题.这里列出参考链接,stackoverflow中这个问题给出了原因解释,这篇文章给出了修改web.config文件解决方

Crystal Report 遇到需要登录的问题

解决方式: The advices for crystal report database connection settings: 1, Using ApplyLogOnInfo method instead of SetDatabaseLogon method. The code example as below: 2, Using “Microsoft OLE DB Provider for SQL Server” instead of “SQL Native Client” as dat

修改水晶报表(Crystal Report 2008)中子报表的宽度

前几天应公司要求在原有的水晶报表(Crystal Report 2008)模板的子报表中添加新列,可是在修改过程中发现因为之前添加子报表时设置的宽度较小(15cm),现在没有位置可以加入新的列(不能减少其他列的宽度),所以需要增加子报表的宽度,但在主报表中调整了子报表的宽度后不起作用.网上搜索了一下,并没有明确的答案,不过有设置主报表宽度的解决方法,即在页面设置中调整水平值(宽度值),根据这个解决方法,我在子报表的页面设置中调整了水平值,成功解决该问题. 该问题的解决方法很简单,但因为一直以为页