Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
80
export to excel
posted

hello i try to export a ultragrid to excel but it changes the data format. my code is:

Public Sub gmt_Exportar_Excel(ByVal Grilla As UltraWinGrid.UltraGrid, Optional NombreArchivo As String = "")
Try
Dim uge_Exportar As New UltraGridExcelExporter
Dim sfd_Dialogo As New System.Windows.Forms.SaveFileDialog

sfd_Dialogo.Filter = "Libros de Excel (*.xlsx)|*.xlsx|Todos Los Archivos (*.*)|*.*"
sfd_Dialogo.DefaultExt = "xlsx"
sfd_Dialogo.FilterIndex = 1
sfd_Dialogo.Title = "Exportar a ..."
If NombreArchivo.Trim <> "" Then
sfd_Dialogo.FileName = NombreArchivo
Else
sfd_Dialogo.FileName = "LibroEOS"
End If
Dim result As DialogResult = sfd_Dialogo.ShowDialog()
If result = DialogResult.Cancel Then Return
Dim stNombreArchivo As String = sfd_Dialogo.FileName

uge_Exportar.Export(Grilla, stNombreArchivo, Infragistics.Documents.Excel.WorkbookFormat.Excel2007)
If MessageBox.Show("Se ha exportado satisfactoriamente el archivo, desea poder visualizarlo?", _
"CONTASOL", MessageBoxButtons.YesNo, MessageBoxIcon.Question) = DialogResult.Yes Then
Process.Start(stNombreArchivo)
End If

Catch ex As Exception
Throw ex
End Try
End Sub

the grid looks like this:

grid1

and in excel looks like this:

grid2

thx for your help

Parents
No Data
Reply
  • 469350
    Suggested Answer
    Offline posted

    The second image you posted here is too small to see. So I'm not exactly sure what the issue is. But it sounds like you are talking about the Format property of the column. The Format in the grid cannot be applied to Excel directly because DotNet formats are not always the same as Excel formats. So what you need to do is handle the InitializeColumn event of the UltraGridExcelExporter and translate the format from Dotnet format into an appropriate Excel format.

    Most of the time, you can just do this:

    e.ExcelFormatStr = e.FrameworkFormatStr.

Children
No Data