JIDE 3.5.15

com.jidesoft.hssf
Class HssfTableUtils.ContextSensitiveCellValueConverter

java.lang.Object
  extended by com.jidesoft.hssf.HssfTableUtils.ContextSensitiveCellValueConverter
All Implemented Interfaces:
ValueConverter, HssfTableUtils.CellValueConverter
Enclosing class:
HssfTableUtils

public static class HssfTableUtils.ContextSensitiveCellValueConverter
extends Object
implements HssfTableUtils.CellValueConverter

Converts the cell value in a table to the value that will be written to Excel cell. The benefit of this converter is that you would get almost the same visible contents in Excel as you run your application. However, the side effect is that everything in Excel at the start point would be String instead of its original type. In this case, the return value of getDataFormat does not take effect.


Constructor Summary
HssfTableUtils.ContextSensitiveCellValueConverter()
           
 
Method Summary
 Object convert(JTable table, Object value, int rowIndex, int columnIndex)
          Converts the value to the value you want to set in the csv file.
 int getDataFormat(JTable table, Object value, int rowIndex, int columnIndex)
          Gets the data format for the value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

HssfTableUtils.ContextSensitiveCellValueConverter

public HssfTableUtils.ContextSensitiveCellValueConverter()
Method Detail

convert

public Object convert(JTable table,
                      Object value,
                      int rowIndex,
                      int columnIndex)
Description copied from interface: ValueConverter
Converts the value to the value you want to set in the csv file.

Specified by:
convert in interface ValueConverter
Parameters:
table - the table
value - the value in the table
rowIndex - the row index of the value
columnIndex - the column index of the value
Returns:
the converted value.

getDataFormat

public int getDataFormat(JTable table,
                         Object value,
                         int rowIndex,
                         int columnIndex)
Description copied from interface: HssfTableUtils.CellValueConverter
Gets the data format for the value. The formats are defined in POI's HSSF. Available formats are

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 undocumented 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 for "@"

If you need to access the HSSFWorkbook instance used during this exporting process, you can get it using table.getClientProperty("HssfTableUtils.HSSFWorkbook").

Specified by:
getDataFormat in interface HssfTableUtils.CellValueConverter
Parameters:
table - the table
value - the value in the table
rowIndex - the row index of the value
columnIndex - the column index of the value
Returns:
the data format as defined above. -1 if you don't care and use the default format.

JIDE 3.5.15