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");
答案 0 :(得分: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.