public class POICellFormatter extends Object
POICellFormatterのインスタンスを生成して利用します。
formatAsString(Cell)を利用します。format(Cell)の結果であるCellFormatResultから取得します。formatAsString(Cell, Locale)でロケールを直接指定します。
POICellFormatter cellFormatter = new POICellFormatter ();
Cell cell = // セルの取得
String text1 = cellForrmatter.formatAsString(cell);
// ロケールに依存する書式の場合
String text2 = cellForrmatter.formatAsString(cell, Locale.US);
// 文字色の条件が設定されている場合
CellFormatResult result = cellForrmatter.format(cell);
String text3 = result.getText(); // フォーマット結果の文字列
MSColor textColor = result.getTextColor(); // 書式の文字色
| コンストラクタと説明 |
|---|
POICellFormatter() |
| 修飾子とタイプ | メソッドと説明 |
|---|---|
CellFormatResult |
format(Cell cell)
セルの値を取得する
|
CellFormatResult |
format(Cell cell,
Locale locale)
ロケールを指定してセルの値を取得する
|
String |
formatAsString(Cell cell)
セルの値を文字列として取得する
|
String |
formatAsString(Cell cell,
Locale locale)
ロケールを指定してセルの値を文字列として取得する
|
FormatterResolver |
getFormatterResolver()
FormatterResolverを取得する。 |
boolean |
isCache()
パースしたフォーマッタをキャッシュするかどうか。
|
boolean |
isConsiderMergedCell()
結合されたセルを考慮するかどうか。
|
boolean |
isErrorCellAsEmpty()
エラーセルの値を空文字として取得するかどうか。
|
boolean |
isThrowFailEvaluateFormula()
式を評価する際に失敗したときに、例外
FormulaEvaluateExceptionをスローするかどうか。 |
void |
setCache(boolean cache)
パースしたフォーマッタをキャッシュするかどうか設定する。
|
void |
setConsiderMergedCell(boolean considerMergedCell)
結合されたセルを考慮するかどうか。
|
void |
setErrorCellAsEmpty(boolean errorCellAsEmpty)
エラーセルの値を空文字として取得するかどうか設定する。
|
void |
setFormatterResolver(FormatterResolver formatterResolver)
FormatterResolverを設定する。 |
void |
setThrowFailEvaluateFormula(boolean throwFailEvaluateFormula)
式を評価する際に失敗したときに、例外
FormulaEvaluateExceptionをスローするかどうか設定する。 |
public String formatAsString(Cell cell)
cell - 取得対象のセルpublic String formatAsString(Cell cell, Locale locale)
cell - フォーマット対象のセルlocale - locale フォーマットしたロケール。nullでも可能。
ロケールに依存する場合、指定したロケールにより自動的に切り替わります。public CellFormatResult format(Cell cell)
cell - フォーマット対象のセルpublic CellFormatResult format(Cell cell, Locale locale)
cell - フォーマット対象のセルlocale - locale フォーマットしたロケール。nullでも可能。
ロケールに依存する場合、指定したロケールにより自動的に切り替わります。public FormatterResolver getFormatterResolver()
FormatterResolverを取得する。public void setFormatterResolver(FormatterResolver formatterResolver)
FormatterResolverを設定する。
独自のものに入れ替える際に利用します。formatterResolver - public boolean isCache()
public void setCache(boolean cache)
cache - true:キャッシュする。public boolean isErrorCellAsEmpty()
public void setErrorCellAsEmpty(boolean errorCellAsEmpty)
errorCellAsEmpty - true:空文字として取得する。public boolean isThrowFailEvaluateFormula()
FormulaEvaluateExceptionをスローするかどうか。
初期値はfalseで、式の評価に失敗したときは、エラーセルとして扱われます。
public void setThrowFailEvaluateFormula(boolean throwFailEvaluateFormula)
FormulaEvaluateExceptionをスローするかどうか設定する。throwFailEvaluateFormula - true: 例外をスローする。public boolean isConsiderMergedCell()
POIの場合、結合されている領域は、左上のセル以外はブランクセルとなるため、値が設定してあるセルを操作する必要がある。
初期値はtrueで、ブランクセルを結合セルと見なして処理を行います。
public void setConsiderMergedCell(boolean considerMergedCell)
POIの場合、結合されている領域は、左上のセル以外はブランクセルとなるため、値が設定してあるセルを走査する必要がある。
considerMergedCell - true:結合セルを考慮して処理を行う。Copyright © 2021 mygreen. All rights reserved.