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.
Any Suggestions?
Ok, my merged cells export is working properly now.
I have only one question, is there a way to retain the color of my cells from ultragrid to excel?