Hello guys, I'm trying to export my ultragrid with merged cells to excel,
but excel is not respecting the merged cells. How can I solve this?
I tried this using the following code:
Private
Sub UltraGridExcelExporter1_CellExported(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.CellExportedEventArgs) Handles UltraGridExcelExporter1.CellExported
Dim cell As UltraGridCell = e.GridRow.Cells(e.GridColumn)
Dim mergedCell() As UltraGridCell = cell.GetMergedCells()
If Not mergedCell Is Nothing Then
Dim isFirstCell As Boolean = True
For Each mergedCell1 As UltraGridCell In mergedCell
If cell.Row.Index > mergedCell1.Row.Index Then
isFirstCell =
False
Return
End If
If isFirstCell Then
Dim rowIndex As Integer = e.CurrentRowIndex
Dim colIndex As Integer = e.CurrentColumnIndex
e.CurrentWorksheet.MergedCellsRegions.Add(rowIndex, colIndex, rowIndex + (mergedCell.Length - 1), colIndex)
Next
End
Sub
But in this line code
I'm getting this exception and I don´t know why.
"Merged cell regions can't overlap"
The appearance of my ultragrid is shown in the picture.
Help me please.
Hi Mike,
Look at the picture, that's the problem that I'm having , I got no colors in excel.
This is the code that I'm using for now to export my ultragrid to excel.
Private Sub btnExport_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnExport.Click
Me.SaveFileDialog1.Filter = "xls files (*.xls)|*.xls|All files (*.*)|*.*"
If Me.SaveFileDialog1.ShowDialog = Windows.Forms.DialogResult.OK Then
Me.UltraGridExcelExporter1.Export(Me.UltraGrid1, Me.SaveFileDialog1.FileName)
Process.Start(
Me.SaveFileDialog1.FileName)
Sub Private Sub UltraGridExcelExporter1_CellExported(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.CellExportedEventArgs) Handles UltraGridExcelExporter1.CellExported
For Each mergedCell1 In mergedCell
e.CurrentWorksheet.MergedCellsRegions.Add(e.CurrentRowIndex, e.CurrentColumnIndex, e.CurrentRowIndex + (mergedCell.Length - 1), e.CurrentColumnIndex)
End Sub
Note: by the way, I'm using excel 2003, I don't know if that could be a reason of this behavior.
Any suggestion or solution?
I was wondering too if you can attach a example of this that work properly.
Regards
Suggestions??????
SuggestionS!!!!!