Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
c#
c#
ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create(ExcelApplication.FileFormat.Xlsx);

//--- Create a percentage style and assign
//--- a number format to it.
GlobalStyle stylPercent = wb.CreateStyle();
stylPercent.NumberFormat = "0.00%";

//--- Assign a numeric value and
//--- stylPercent to cell A4 to display
//--- 56.30% in the cell.
ws.Cells["A4"].Value = "0.563";
ws.Cells["A4"].Style = stylPercent;

...

Code Block
c#
c#
ExcelApplication xla = new ExcelApplication();
Workbook wb = xla.Create(ExcelApplication.FileFormat.Xlsx);

GlobalStyle stylCurrency = wb.CreateStyle();
NumberFormat numFormat = wb.NumberFormat;
String acctFormat = numFormat.CreateAccounting(2, true, NumberFormat.Color.Red);
stylCurrency.NumberFormat = acctFormat;

Area ar = wb.Worksheets[0].CreateArea("B7:H24");
ar.ApplyStyle(stylCurrency);