vb.net 水晶报表 导出Excel

Protected Sub Page_Load(ByVal sender As Object,ByVal e As System.EventArgs) Handles Me.Load Try p_strNendo = Session("p_strNendo") 'フォーム・CrystalReportViewerのサイズを設定 'crvShiwakecho.Height = Common_AppSet.g_intHRptViewerHeight 'crvShiwakecho.Width = Common_AppSet.g_intHRptViewerWidth 'レポートビューアに表示 Dim objDtbl As DataTable = Session("dsShiwakecho").Tables("dt21_Shiwakecho") Dim objCR As ReportDocument = New ReportDocument() objCR.Load(Common_AppSet.g_strReportTemplate & "rpt21_Shiwakecho.rpt") objCR.SetDataSource(objDtbl) 'crvShiwakecho.ToolPanelView = ToolPanelViewType.None crvShiwakecho.ReportSource = objCR 'パラメータフィールドに値を設定 Dim pfFields As New CrystalDecisions.Shared.ParameterFields Dim pfNendo As New CrystalDecisions.Shared.ParameterField Dim pvNendo As New CrystalDecisions.Shared.ParameterDiscreteValue pfNendo.ParameterFieldName = "prmNendo" pvNendo.Value = p_strNendo pfNendo.CurrentValues.Add(pvNendo) pfFields.Add(pfNendo) crvShiwakecho.ParameterFieldInfo = pfFields Dim opts As CrystalDecisions.Shared.DiskFileDestinationOptions = New CrystalDecisions.Shared.DiskFileDestinationOptions() opts.DiskFileName = "C:\PPPWebLoader\234.xls" Dim myExportOptions As CrystalDecisions.Shared.ExportOptions = objCR.ExportOptions myExportOptions.DestinationOptions = opts myExportOptions.ExportDestinationType = CrystalDecisions.Shared.ExportDestinationType.DiskFile Response.ContentType = "application/vnd.ms-excel" myExportOptions.ExportFormatType = CrystalDecisions.Shared.ExportFormatType.Excel For i As Integer = 0 To pfFields.Count - 1 objCR.SetParameterValue(pfFields.Item(i).Name,pfFields.Item(i).CurrentValues) Next objCR.Export() Response.End() Catch ex As Exception Throw New Exception("仕訳帳の出力に失敗しました。" & vbCrLf & ex.StackTrace & vbCrLf & ex.Message) End Try End Sub

相关文章

Format[$] ( expr [ , fmt ] ) format 返回变体型 format$ 强...
VB6或者ASP 格式化时间为 MM/dd/yyyy 格式,竟然没有好的办...
在项目中添加如下代码:新建窗口来显示异常信息。 Namespace...
转了这一篇文章,原来一直想用C#做k3的插件开发,vb没有C#用...
Sub 分列() ‘以空格为分隔符,连续空格只算1个。对所选...
  窗体代码 1 Private Sub Text1_OLEDragDrop(Data As Dat...