0

i want to generate Excel file using c#. Am using NPOI XSSFWorkbook class. while printing a decimal value in Excel sheet i want to give it Accounting formatting.

For Example my data should look like $35.00. But am not able to achieve it using XSSFWorkbook class. i have already tried
CellStyle.DataFormat = _workbook.CreateDataFormat().GetFormat("#,##0");

Gowtham Shiva
  • 3,802
  • 2
  • 11
  • 27
  • please check the answer at [https://stackoverflow.com/questions/43283268/why-npoi-created-cell-drop-down-list-always-split-by-comma/44955100#44955100 link. if formatting doesn't work, you can replace format pattern with the pattern provided by shrikant. – kumar chandraketu Aug 07 '17 at 13:57

1 Answers1

0

Try first set the style for your cell and then change it Format attribute, but with custom format like this:

IDataFormat dataFormatCustom = workbook.CreateDataFormat();
cell.CellStyle = styles["cell"]; 
cell.CellStyle.DataFormat = dataFormatCustom.GetFormat("_($* #,##0.00_);_($* (#,##0.00);_($* ""-""??_);_(@_)");

May be this will work i am not sure.

Shrikant
  • 523
  • 4
  • 15