none
Erro ao Exportar Relatorio do Crystal Report para Html RRS feed

  • Pergunta

  • Pessoal,
    estou tentando exportar um relatorio do Crystal Report para Html

     

    'exportar o relatório para HTML sem print preview
    Dim crReportDocument As New ReportDocument
    Dim strConexao As SqlConnection = New SqlConnection
    strConexao.ConnectionString = Aqui a COnexão
    Dim strSQL As New StringBuilder
    Dim oTable As New DataTable()

    Try
    '1 passo: carregar o relatório
    D
    im strPathreport As String = Server.MapPath("CRimprimir_liberacao.rpt")
    crReportDocument.Load(strPathreport)
    '2 passo: passar os dados para o relatório (datatable)
    'abrindo conexão com o banco de dados
    'oConn.ConnectionString = strConexao
    strConexao.Open()
    Dim cm As SqlClient.SqlCommand = strConexao.CreateCommand
    cm.CommandType = CommandType.StoredProcedure
    cm.CommandText =
    "wp_liberacao"
    cm.Parameters.Add("@codigo", SqlDbType.Int).Value = Request.QueryString("CodVeiculo")
    cm.Parameters.Add(
    "@data", SqlDbType.VarChar).Value = Request.QueryString("dataini")
    cm.ExecuteNonQuery()
    Dim oDA As New SqlClient.SqlDataAdapter(cm)
    oDA.Fill(oTable)
    'definindo o DataSource do relatório
    crReportDocument.SetDataSource(oTable)

    'exportando o arquivo para html
    Dim crExportOptions As ExportOptions = New ExportOptions
    Dim crDiskFileDestinationOptions As DiskFileDestinationOptions
    Dim strHTMTmp As String = Server.MapPath("~") & "\" & Session.SessionID.ToString & ".htm"
    Dim HTML40Formatopts As HTMLFormatOptions = New HTMLFormatOptions
    crExportOptions.ExportDestinationType = ExportDestinationType.DiskFile
    crExportOptions.ExportFormatType = ExportFormatType.HTML40
    HTML40Formatopts.HTMLBaseFolderName = strHTMTmp
    HTML40Formatopts.HTMLFileName =
    "HTML40.html"
    HTML40Formatopts.HTMLEnableSeparatedPages = True
    HTML40Formatopts.HTMLHasPageNavigator = True
    HTML40Formatopts.FirstPageNumber = 1
    HTML40Formatopts.LastPageNumber = 3
    crExportOptions.FormatOptions = HTML40Formatopts
    crReportDocument.Export()

     

    Catch ex As Exception
    ScriptManager.RegisterClientScriptBlock(Me, GetType(Page), "", "<script>alert('ERRO: " & ex.ToString & "!');</script>", False)
    Finally
    'liberando os objetos
    strConexao.Dispose()
    oTable.Dispose()
    strConexao =
    Nothing
    oTable = Nothing
    End Try

    Dai gera um erro: Invalid Export DLL ou Export Format

    Alguem pode me ajudar, esta faltando uma linha de codigo.
    peguei neste link
    http://www.codeproject.com/KB/cs/letaonarticle2.aspx?fid=38307&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=1450842


    Mcelmo
    quarta-feira, 8 de abril de 2009 17:53