Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
60
UltraGridExcelExporter Summary values are formatted as text in Excel
posted

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?

Parents
  • 469350
    Suggested Answer
    Offline posted

    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";
            }

Reply Children