RE:Problema al exportar a excel desde Crystal Repo
La forma en que me conecto es la siguiente o mas bien te envio el codigo con que lo realizo, y ademas le envio algunos parametros segun sea el reporte....(rptParametros: es el componente de Crystal)
rptParametros.Connect = "DSN=" & m_Coneccion.NombreServidor & ";" & "UID=" & m_Coneccion.CodigoUsuarioSQL & ";" & "PWD=" & m_Coneccion.ClaveUsuarioSQL & ";"
rptParametros.DiscardSavedData = True
rptParametros.ReportFileName = strRutaBaseDatos & "InventarioProveedor.rpt"
rptParametros.Formulas(0) = "Compania= '" & m_Compania.Nombre & "'"
rptParametros.Formulas(1) = "Usuario= '" & General.RegIdentificacion.IDMaquina & "'"
rptParametros.Formulas(2) = "TipoCambio = " & mskTipoCambio
rptParametros.Formulas(4) = "FechaIni= '" & dtpFechaIni & "'"
rptParametros.Formulas(5) = "FechaFin= '" & dtpFechaFin & "'"
If optAcumulado.Value Then
rptParametros.Formulas(3) = "Resumen = 'S'"
Else
rptParametros.Formulas(3) = "Resumen = 'N'"
End If
rptParametros.WindowState = crptMaximized
strSeleccion = "{INV_INVENTARIO.CIA_Codigo} = '" & m_Compania.Codigo & "'"
If cboClasificacion.Text <> "" Then
strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_INVENTARIO.CLA_Codigo} = '" & cboClasificacion & "'"
End If
If lblBodega <> "" And m_strBodega <> "" Then
strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_X_BODEGA.BOD_Bodega} = '" & m_strBodega & "'"
End If
If lblDepto <> "" And m_strDepto <> "" Then
strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_INVENTARIO.DEP_Codigo} = '" & m_strDepto & "'"
End If
If lblFamilia <> "" And m_strFamilia <> "" Then
strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_INVENTARIO.FAM_Codigo} = '" & m_strFamilia & "'"
End If
If lblProve <> "" And m_strProve <> "" Then
strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_INVENTARIO.Pro_Codigo} = '" & m_strProve & "'"
End If
If lblArticulo.Caption <> "" And m_strArticulo <> "" Then
strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_X_BODEGA.INV_CODIGO} = '" & m_strArticulo & "'"
End If
'
' If chkDesactivarCodigo.Value = 1 Then
' strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_INVENTARIO.INV_Desactivado} =1 "
' rptParametros.Formulas(4) = "Titulo = '" & "Artículos Desactivados" & "'"
' Else
' strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_INVENTARIO.INV_Desactivado} = 0 "
' rptParametros.Formulas(4) = "Titulo = '" & "Artículos Activados" & "'"
' End If
'
' strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "{INV_X_BODEGA.INV_Disponible} > 0"
' /* Da como opcion de imprimir saldos < menor cero o > mayor a cero */
If chkSaldo.Value = 1 Then
strSeleccion = strSeleccion & IIf(strSeleccion = "", "", " AND ") & "({INV_INVENTARIO.INV_DISPONIBLE}<>0 OR " & _
"{INV_INVENTARIO.INV_DISPONIBLE} <> 0) "
End If
rptParametros.ReplaceSelectionFormula strSeleccion
rptParametros.WindowShowPrintSetupBtn = True
rptParametros.WindowShowSearchBtn = True
rptParametros.Action = 1
chkDesactivarCodigo.Value = 0