1. Common
HSSFSheet lo_sheet = (HSSFSheet) lo_workbook.CreateSheet ("sheet ");
HSSFCellStyle lo_Style = (HSSFCellStyle) lo_workbook.CreateCellStyle ();
Lo_Style.DataFormat = HSSFDataFormat. GetBuiltinFormat ("@");
2. Special amount
// Amount
CellStyle styleMony = workbook. CreateCellStyle ();
DataFormat format = workbook. CreateDataFormat ();
StyleMony. DataFormat = format. GetFormat ("$ #,## 0.00 ");
If the time format is d-mmm-yy:
CellStyle styledate = workbook. CreateCellStyle ();
DataFormat format = workbook. CreateDataFormat ();
Styledate. DataFormat = format. GetFormat ("d-mmm-yy ");
The actual format is d-mmm;
You can use the following method:
CellStyle styledate = workbook. CreateCellStyle ();
// DataFormat formatTime = workbook. CreateDataFormat ();
Styledate. DataFormat = 0xf; // d-mmm-yy
This problem may be caused by the NPOI version. Version 1.2.3.0
For more information about the HSSFDataFormat parameter, see the comments section in the source code.
0, "General"
1, "0"
2, 0.00"
3, "#, #0"
4, "# ,## 0.00"
5, "($ #, #0 _); ($ #, #0 )"
6, "($ #, #0 _); [Red] ($ #, #0 )"
7, "($ #,## 0.00); ($ #,## 0.00 )"
8, "($ #, #0.00 _); [Red] ($ #, #0.00 )"
9, "0%"
0xa, "0.00%"
0xb, "0.00E + 00"
0xc ,"#? /? "
0xd ,"#?? /?? "
0xe, "m/d/yy"
0xf, "d-mmm-yy"
0x10, "d-mmm"
0x11, "mmm-yy"
0x12, "h: mm AM/PM"
0x13, "h: mm: ss AM/PM"
0x14, "h: mm"
0x15, "h: mm: ss"
0x16, "m/d/yy h: mm"
0x17-0x24 reserved for international and unmarshented
0x25, "(#, #0 _); (#, #0 )"
0x26, "(#, #0 _); [Red] (#, #0 )"
0x27, "(#,# 0.00 _); (#,## 0.00 )"
0x28, "(#, #0.00 _); [Red] (#, #0.00 )"
0x29, "_ (// #, #0 _); _ (// (#, #0 ); _(///\"-\"_);_(@_)"
0x2a, "_ ($ // #, #0 _); _ ($ // (#, #0 ); _ ($ ///\"-\"_);_(@_)"
0x2b, "_ (// #, #0.00 _); _ (// (#,## 0.00 ); _(///\"-\"?? _);_(@_)"
0x2c, "_ ($ // #, #0.00 _); _ ($ // (#,# 0.00 ); _ ($ ///\"-\"?? _);_(@_)"
0x2d, "mm: ss"
0x2e, "[h]: mm: ss"
0x2f, "mm: ss.0"
0x30, "# 0.0E + 0"
0x31, "@"-This Is text format.
0x31 "text"-Alias "@"
1. Common
HSSFSheet lo_sheet = (HSSFSheet) lo_workbook.CreateSheet ("sheet ");
HSSFCellStyle lo_Style = (HSSFCellStyle) lo_workbook.CreateCellStyle ();
Lo_Style.DataFormat = HSSFDataFormat. GetBuiltinFormat ("@");
2. Special amount
// Amount
CellStyle styleMony = workbook. CreateCellStyle ();
DataFormat format = workbook. CreateDataFormat ();
StyleMony. DataFormat = format. GetFormat ("$ #,## 0.00 ");
If the time format is d-mmm-yy:
CellStyle styledate = workbook. CreateCellStyle ();
DataFormat format = workbook. CreateDataFormat ();
Styledate. DataFormat = format. GetFormat ("d-mmm-yy ");
The actual format is d-mmm;
You can use the following method:
CellStyle styledate = workbook. CreateCellStyle ();
// DataFormat formatTime = workbook. CreateDataFormat ();
Styledate. DataFormat = 0xf; // d-mmm-yy
This problem may be caused by the NPOI version. Version 1.2.3.0
For more information about the HSSFDataFormat parameter, see the comments section in the source code.
0, "General"
1, "0"
2, 0.00"
3, "#, #0"
4, "# ,## 0.00"
5, "($ #, #0 _); ($ #, #0 )"
6, "($ #, #0 _); [Red] ($ #, #0 )"
7, "($ #,## 0.00); ($ #,## 0.00 )"
8, "($ #, #0.00 _); [Red] ($ #, #0.00 )"
9, "0%"
0xa, "0.00%"
0xb, "0.00E + 00"
0xc ,"#? /? "
0xd ,"#?? /?? "
0xe, "m/d/yy"
0xf, "d-mmm-yy"
0x10, "d-mmm"
0x11, "mmm-yy"
0x12, "h: mm AM/PM"
0x13, "h: mm: ss AM/PM"
0x14, "h: mm"
0x15, "h: mm: ss"
0x16, "m/d/yy h: mm"
0x17-0x24 reserved for international and unmarshented
0x25, "(#, #0 _); (#, #0 )"
0x26, "(#, #0 _); [Red] (#, #0 )"
0x27, "(#,# 0.00 _); (#,## 0.00 )"
0x28, "(#, #0.00 _); [Red] (#, #0.00 )"
0x29, "_ (// #, #0 _); _ (// (#, #0 ); _(///\"-\"_);_(@_)"
0x2a, "_ ($ // #, #0 _); _ ($ // (#, #0 ); _ ($ ///\"-\"_);_(@_)"
0x2b, "_ (// #, #0.00 _); _ (// (#,## 0.00 ); _(///\"-\"?? _);_(@_)"
0x2c, "_ ($ // #, #0.00 _); _ ($ // (#,# 0.00 ); _ ($ ///\"-\"?? _);_(@_)"
0x2d, "mm: ss"
0x2e, "[h]: mm: ss"
0x2f, "mm: ss.0"
0x30, "# 0.0E + 0"
0x31, "@"-This Is text format.
0x31 "text"-Alias "@"