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 Trausti,
Try calling PerformAutoSize on the column in the export layout inside the BeginExport event of the UltraGridExcelExporter.
Thanks for the reply Mike.
PerformAutoResize on the column while exporting did not change anything.
Thanks for the follow up.
No, that changed nothing. I can see it changing the column width in HeaderCellExporting, but the Excel sheet is created as before.
Can you confirm if this is a bug in latest version or if this has been fixed in a HotFix?
Hello ,
I am not exactly sure what is the issue here. So I have created a sample, where I have implement my suggestion. Please see the attached sample and also the video. Please let me know what I am missing.
I am waiting for your response.
Thanks for that. This is not enough to trigger the bug. You need this line in InitializeLayout (which is vital for me):
band.PerformAutoResizeColumns(False, UltraWinGrid.PerformAutoSizeType.AllRowsInBand, True)
This is what kills it. Without this, the columns are wide enough to start with so the issue does not come up. The auto resize reduces the width of the columns and now the group text does not fit in Excel.
Hristo,
I got this to work. I made few changes to the code you included in your example:
1. Removed this from Initialize Layout:
myGroup.RowLayoutGroupInfo.LabelPosition = UltraWinGrid.LabelPosition.LabelOnly
2. Added this in Initialize Layout:
band.PerformAutoResizeColumns(True, UltraWinGrid.PerformAutoSizeType.AllRowsInBand, True)
3. In HeaderCellExporting, ensure sizing is only done on the last column in the group:
Private Sub exp_HeaderCellExporting(ByVal sender As System.Object, ByVal e As Infragistics.Win.UltraWinGrid.ExcelExport.HeaderCellExportingEventArgs) Handles exp.HeaderCellExporting If Not e.GridHeader.Column Is Nothing AndAlso e.GridHeader.Column.Index = e.GridHeader.Column.Group.Columns.Count - 1 Then e.CurrentWorksheet.Columns(e.CurrentColumnIndex).Width = (e.GridHeader.Column.RowLayoutColumnInfo.ActualCellSize.Width) * (256 / grd.Font.Size) End If End Sub
This resulted in a correct export:
Is this going to be fixed in feture release?
I am glad to hear that my sample helps you to find solution for your issue.
As I mentioned in my previous post, where I have provided you a sample named “WinGridRowLayputExcelExporting”, everything work just fine in Infragistics 11.1. So my suggestion is to compare the code generated from the designer from the “WinGridRowLayputExcelExporting” with your code in order to find the difference which causes your issue.
Please let me know if you have any further questions.