Using :
this.ultraGridExcelExporter1.Export(this.ultraGrid1, fileName);
having a summery defined as:
SummarySettings sumSetting = e.Layout.Bands[0].Summaries.Add(SummaryType.Sum, e.Layout.Bands[0].Columns["Qty"], SummaryPosition.UseSummaryPositionColumn);
sumSetting.DisplayFormat = "{0:0.00}";
sumSetting.Appearance.TextHAlingn = HAlign.Right;
makes the cell in Excel containing the summary value formatted as string, not a numeric value... Removing the formatting in SummaryCellExporting event has noe effect:
e.Summary.SummarySettings.Appearance.TextHAlign = HAlign.Default;
e.Summary.SummarySettings.DisplayFormat = string.Empty;
All other cell values are formatted correctly, is this a known issue?
Hi,
I think the summary cells are exported as text intentionally, so as not to lose any literal text in the formatting. You don't have any literals in your DisplayFormat, but the default summaries do.
You could easily work around this by handling the SummaryCellExported event and writing the value and the format directly to the cell.
private void ultraGridExcelExporter1_SummaryCellExported(object sender, Infragistics.Win.UltraWinGrid.ExcelExport.SummaryCellExportedEventArgs e) { Worksheet ws = e.CurrentWorksheet; WorksheetRow wsRow = ws.Rows[e.CurrentRowIndex]; WorksheetCell wsCell = wsRow.Cells[e.CurrentColumnIndex]; wsCell.Value = e.Summary.Value; // Note that DotNet formats and Excel format are not the same. So you can't just // set the FormatString to e.Summary.SummarySettings.DisplayFormat. You have to // translate it into a format Excel can understand. wsCell.CellFormat.FormatString = "0.00"; }
Thanks, that solved my issue!
You could use the Tag property on the SummarySettings to store the format you want and then use that Tag in SummaryCellExported event.
For the grid, there are maybe more than 20 columns with Summary(sum,average,formula,...), the formats are different with each other, is there any approvach to attach this excel format(wsCell.CellFormat.FormatString) onto the SummarySetting object? or something similar method to achieve it.
Thanks.