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
20
Format WebCurrencyEdit columns as numbers?
posted

I'm handling the UltraWebGridExcelExporter's OnInitializeColumn event in order to provide format currency properly in Excel.  Here's an example of the method I typically use:

protected void uwgExcelExporter_InitializeColumn(object sender, InitializeColumnEventArgs e)
{
   switch (e.Column.Key)
   {
      case "Target":
      case "Adjustment":
      case "AdjustedTarget":
      case "Difference":
         e.ExcelFormatString = EXCEL_FORMAT_CURRENCY;
         break;
      case "PercentageDifference":
         e.ExcelFormatString = EXCEL_FORMAT_PERCENTAGE;
         break;
   }
}

When the column contains a WebCurrencyEdit control, this doesn't work properly and the numbers are exported to Excel as text.  Does anyone know how to get around this?

  • 5118
    posted

    Hello,

    I usually use the CellExporting (for pre-processing) and CellExported (for post-processing) events to tweak the data being sent into Excel... Try handling one of those events instead.  Inside these event handlers see what column the cell belongs to and if it is the one with your WebCurrencyEdit adjust the value and format there.