Top Description Fields Constructors Methods
org.apache.poi.hssf.usermodel

public final Class HSSFDataFormat

extends Object
implements DataFormat
Class Inheritance
All Implemented Interfaces
org.apache.poi.ss.usermodel.DataFormat
Imports
java.util.Arrays, .Iterator, .List, .Vector, org.apache.poi.hssf.model.InternalWorkbook, org.apache.poi.hssf.record.FormatRecord, org.apache.poi.ss.usermodel.BuiltinFormats, .DataFormat

Identifies both built-in and user defined formats within a workbook.

See BuiltinFormats for a list of supported built-in formats.

International Formats
Since version 2003 Excel has supported international formats. These are denoted with a prefix "[$-xxx]" (where xxx is a 1-7 digit hexadecimal number).

See Also
Review guidelines for customizing a number format

Field Summary

Modifier and TypeField and Description
private static final String[]
private final Vector<String>
private boolean
private final InternalWorkbook

Constructor Summary

AccessConstructor and Description
pack-priv
HSSFDataFormat(InternalWorkbook
the workbook the formats are tied to.
workbook
)

Constructs a new data formatter.

Method Summary

Modifier and TypeMethod and Description
private void
ensureFormatsSize(int index)

Ensures that the formats list can hold entries up to and including the entry with this index

public static short

Returns:

index of format or -1 if undefined.
getBuiltinFormat
(String
string matching a built in format
format
)

get the format index that matches the given format string

Automatically converts "text" to excel's format string to represent text.

public static String

Returns:

string represented at index of format or null if there is not a builtin format at that index
getBuiltinFormat
(short
of a built in format
index
)

get the format string that matches the given format index

public static List<String>
public short

Returns:

index of format.
getFormat
(String
string matching a built in format
pFormat
)

Implements org.apache.poi.ss.usermodel.DataFormat.getFormat.

Get the format index that matches the given format string, creating a new format entry if required.

public String

Returns:

string represented at index of format or null if there is not a format at that index
getFormat
(short
of a format
index
)

Implements org.apache.poi.ss.usermodel.DataFormat.getFormat.

get the format string that matches the given format index

public static int

Returns:

number of built-in and reserved builtinFormats
getNumberOfBuiltinBuiltinFormats
()

get the number of built-in and reserved builtinFormats

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

_builtinFormatsback to summary
private static final String[] _builtinFormats
_formatsback to summary
private final Vector<String> _formats
_movedBuiltinsback to summary
private boolean _movedBuiltins
_workbookback to summary
private final InternalWorkbook _workbook

Constructor Detail

HSSFDataFormatback to summary
pack-priv HSSFDataFormat(InternalWorkbook workbook)

Constructs a new data formatter. It takes a workbook to have access to the workbooks format records.

Parameters
workbook:InternalWorkbook

the workbook the formats are tied to.

Method Detail

ensureFormatsSizeback to summary
private void ensureFormatsSize(int index)

Ensures that the formats list can hold entries up to and including the entry with this index

getBuiltinFormatback to summary
public static short getBuiltinFormat(String format)

get the format index that matches the given format string

Automatically converts "text" to excel's format string to represent text.

Parameters
format:String

string matching a built in format

Returns:short

index of format or -1 if undefined.

getBuiltinFormatback to summary
public static String getBuiltinFormat(short index)

get the format string that matches the given format index

Parameters
index:short

of a built in format

Returns:String

string represented at index of format or null if there is not a builtin format at that index

getBuiltinFormatsback to summary
public static List<String> getBuiltinFormats()
getFormatback to summary
public short getFormat(String pFormat)

Implements org.apache.poi.ss.usermodel.DataFormat.getFormat.

Get the format index that matches the given format string, creating a new format entry if required. Aliases text to the proper format as required.

Parameters
pFormat:String

string matching a built in format

Returns:short

index of format.

getFormatback to summary
public String getFormat(short index)

Implements org.apache.poi.ss.usermodel.DataFormat.getFormat.

get the format string that matches the given format index

Parameters
index:short

of a format

Returns:String

string represented at index of format or null if there is not a format at that index

getNumberOfBuiltinBuiltinFormatsback to summary
public static int getNumberOfBuiltinBuiltinFormats()

get the number of built-in and reserved builtinFormats

Returns:int

number of built-in and reserved builtinFormats