title: Apply Formatting to TotalsRow using EPPlus
body: <p>Using EPPlus I can create the XSLX file and I can apply formatting to the data, but if I use a TotalsRow function, like SUM, then the formatting is not applied. </p>
  
  <p>Does anyone know how to apply that formatting?</p>
  
  <p><strong>Update:</strong></p>
  
  <p>To load the data into a sheet and get the table I do the following (dtMain being a DataTable):     </p>
  
  <pre><code>FileInfo newFile = new FileInfo(@"C:\Temp.xslx");
  
  using (ExcelPackage package = new ExcelPackage(newFile))
  {
      //Create the Worksheet
      var sheet = package.Workbook.Worksheets.Add("Sheet1");
      //Read the table into a sheet
      var range = sheet.Cells["A1"].LoadFromDataTable(dtMain, true);
  
      sheet.Tables.Add(range, "data");
      //Now format the table...
      var tbl = sheet.Tables[0];
      tbl.ShowTotal = true;
  
      //create a custom style
      string stylename = "StyleName";
      var style = package.Workbook.Styles.CreateNamedStyle(stylename);
  
      tbl.Columns[SomeName].TotalsRowFunction = RowFunctions.Sum;
  
      style.Style.Numberformat.Format = "#,###.00";
  
      //assign the style to the column
      tbl.Columns[SomeName].DataCellStyleName = stylename;
  }
  
  range.AutoFitColumns();
  
  // save our new workbook and we are done!
  package.Save();
  </code></pre>