Hello,
I have a grid that has GroupLayout. When the group's text is wider than the total width of the columns in the group, the last column's width is increased so the full text of the groups is shown (I call PerformAutoResizeColumns with includeHeaders = True at the end of InitializeLayout).
Here is an example where one column is in the group and the group's text is wider than the column. In the grid I get what I expect:
Now I export it to Excel using UltragridExcelExporter and it changes the width of the column under the group. It now changed, the width is fitting the column only and does not take the group into account:
I assume this is a bug? Anybody know a way to force this to account for the group?
Thanks,
Trausti
Hi,
I just wanted to know if you were able to solve your issue based on my suggestions or you still need help? Just let me know.
Thank you.
Hello ,
What could you do in your case is to handle HeaderCellExporting event of UltraGridExcelExporter and to write there the following code:
If (e.GridHeader.Group Is Nothing) Then
e.CurrentWorksheet.Columns(e.CurrentColumnIndex).Width = e.GridHeader.Column.Width * (256 / grd.Font.Size)
End If
Please let me know if you have any further questions.
To be more detailed regarding the version I'm using, it's 10.1.20101.1007
Any ideas?
My version is 10.1.
I replicated the issue outside of our application by creating a form with one grid that is bound to UltraDatasource which has two columns. Each column is 30 pixels wide in the grid.
Same thing happens, it looks good on screen and not in Excel. I can see at run time that the width of the group is 60 pixels (total width of the two columns), but it clearly is wider on screen.
Below is my code. Please let me know if you spot something wrong in it.
Thanks!
Private Sub grd_InitializeLayout(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.InitializeLayoutEventArgs) Handles grd.InitializeLayout Dim myGroup As UltraWinGrid.UltraGridGroup Dim band As UltraWinGrid.UltraGridBand Dim col As UltraWinGrid.UltraGridColumn
band = e.Layout.Bands(0)
myGroup = band.Groups.Add("Test") myGroup.RowLayoutGroupInfo.OriginX = 1 myGroup.RowLayoutGroupInfo.OriginY = 0 myGroup.RowLayoutGroupInfo.SpanY = 1 myGroup.RowLayoutGroupInfo.SpanX = 2 myGroup.RowLayoutGroupInfo.LabelPosition = UltraWinGrid.LabelPosition.Top myGroup.RowLayoutGroupInfo.LabelSpan = 1 myGroup.Header.Caption = "Here is a very wide text in the group"
band.RowLayoutStyle = UltraWinGrid.RowLayoutStyle.GroupLayout band.RowLayoutLabelStyle = UltraWinGrid.RowLayoutLabelStyle.Separate
For Each col In band.Columns col.RowLayoutColumnInfo.SpanX = 1 col.RowLayoutColumnInfo.SpanY = 1 col.RowLayoutColumnInfo.OriginX = col.Index + 1 col.RowLayoutColumnInfo.OriginY = 1 col.RowLayoutColumnInfo.LabelPosition = UltraWinGrid.LabelPosition.Top col.Group = myGroup Next
e.Layout.PerformAutoResizeColumns(False, UltraWinGrid.PerformAutoSizeType.AllRowsInBand, True) End Sub
Private Sub UltraButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles UltraButton1.Click Dim expFile As String = "C:\temp\TestExp.xlsx" exp.Export(grd, expFile, Infragistics.Excel.WorkbookFormat.Excel2007) Process.Start(expFile) End Sub
What exactly is the version of the Infragistics controls, that you are using? I have created a sample where I have a grid with “Row Layout with Groups” and when I export the grid, columns and groups in the exported file are with same width as in the UltraGrid.
Please let me know if you have any further questions or I am missing something .