如何在vb6中将水晶报表导出为ex cel

问题描述 投票:0回答:1

我正在尝试将报告导出到msexcel,在Windows Server 2003中可以正常工作,但是当我想在本地执行它(Windows 7)时,它只会告诉我该报告无法导出

这是我使用的代码

Call SetParametros(ReporteCrystal)

    Select Case UCase(cmbTipo.Text)

    Case "PDF"
        ReporteCrystal.ExportOptions.FormatType = crEFTPortableDocFormat
        auxExtension = ".pdf"
    Case "MSWORD"
        ReporteCrystal.ExportOptions.FormatType = crEFTWordForWindows
        auxExtension = ".doc"
    Case "MSEXCEL"
        ReporteCrystal.ExportOptions.FormatType = crEFTExcel97
        auxExtension = ".xls"
    Case "TEXT"
        ReporteCrystal.ExportOptions.FormatType = crEFTTabSeparatedText
        auxExtension = ".txt"
    Case "MSEXCEL(SIN FORMATO)"
        ReporteCrystal.ExportOptions.FormatType = crEFTExcelDataOnly
        auxExtension = ".xls"
    End Select

   If Trim(StrNombreRealDelArchivo) <> "" Then
      strNombreDelReporte = StrNombreRealDelArchivo
   End If



    auxResult = Dir$(crEDTDiskFile & "\", vbDirectory)

   '******************************************************************************
   'SE COMENTO PORQUE NO PERMITIA ELEGIR EL FORMATO DE EXCEL CORRECTO
   'Y NOS ARROJABA UN ERROR CUANDO LO EXPORTABAS
   If UCase(cmbDestino.Text) = "DISCO" Then
     cd1.DialogTitle = "Seleccione la ubicacion del archivo"
     cd1.CancelError = True
     cd1.Filter = Replace(auxExtension, ".", "") & "|*" & auxExtension
     'CD1.Filter = strNombreDelReporte
     cd1.filename = strNombreDelReporte
     cd1.InitDir = crEDTDiskFile 'strMAILFolderContenedorDeDocumentos
     cd1.ShowSave
     auxDestino = cd1.filename
    'auxDestino = auxDestino & " \ " & strNombreDelReporte & auxExtension
   Else
    auxDestino = crEDTDiskFile & "\" & strNombreDelReporte & auxExtension
    'strMAILFolderContenedorDeDocumentos & "\" & strNombreDelReporte & auxExtension
   End If
   '******************************************************************************
'   auxDestino = strMAILFolderContenedorDeDocumentos & "\" & strNombreDelReporte & auxExtension

   If auxDestino = "" Then Exit Sub
   ReporteCrystal.ExportOptions.DiskFileName = auxDestino
   ReporteCrystal.ExportOptions.DestinationType = crEDTDiskFile

   '******************************************************************************
   'SE COMENTO PORQUE NO PERMITIA ELEGIR EL FORMATO DE EXCEL CORRECTO
   'Y NOS ARROJABA UN ERROR CUANDO LO EXPORTABAS
   ReporteCrystal.Export False
   '******************************************************************************

   '--con este codigo se permite exportar el reporte de crystal a excel con el formato del reporte
   'ReporteCrystal.Export True

   If UCase(cmbDestino.Text) = "CORREO" Then
       If strMAILDirigidoA = "" Then MsgBox "No existe correo destino", vbInformation, strSist: Exit Sub
       'Call EnviarAOutlookExpress(strMAILFolderContenedorDeDocumentos & "\" & strNombreDelReporte & auxExtension, strMAILDirigidoA, strMAILCuerpo, strMAILTema)
       ReDim arrMAILadjuntos(0)  '= strMAILFolderContenedorDeDocumentos & "\" & strNombreDelReporte & auxExtension
       arrMAILadjuntos(0) = strMAILFolderContenedorDeDocumentos & "\" & strNombreDelReporte & auxExtension
       frmEnviarCorreo.Show 1
   End If

   MsgBox "El reporte fue enviado", vbInformation, strSist

首先,我没有打开要保存它的目录,但是它已经保存了,但是当要保存在xls中时,它会向我发送错误“无法生成文件”,将其导出为pdf,word,txt时会执行没问题,

vb6
1个回答
0
投票

听起来您没有用于Excel的DLL。在我的运行时部署中,我有crxf_xls.dll和crxf_clx_res_en.dll(英语,您会有另外一个),c:\ Program Files(x86)\ Common Files \ Business Objects \ 3.0 \ bin \

路径也可能会有所不同,具体取决于组件的安装方式和版本。由于您说PDF导出正常,因此搜索crxf_pdf.dll,然后在该位置查找。

© www.soinside.com 2019 - 2024. All rights reserved.