s.o
unread,Jun 24, 2010, 3:31:02 AM6/24/10Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to excella
はじめまして。
s.oと申します。
よろしくお願いいたします。
他のスレッドでBRのセルマージはリスナーのpostParseで。。と言う回答がございましたが、
以下のような方法ではまずいでしょうか。。。
$mergeと言うカスタムタグを作成し、カスタムのTagParserで実装する。
$mergeタグは $merge{2,2,項目A}のようにテンプレートに定義する。
parseの中では、カレント位置から相対で2,2のマージを行い、$:項目Aの値を取得して設定する。
実装してみたところ出来てしまっているのですが、何かまずいことありますでしょうか。。。
あまり理解していないうちわーっと書いたので他処理で問題などおきないか心配です。
ちなみに、
深い入れ子の関係で利用するつもりはありません。
罫線までまだ考えていません
以下ソースです。
parse(){
//セルの値取得
PoiUtil.getCellValue(tagCell);
・・・
$merge{2,2,項目A}を取得して、文字列を分解
・・・
ReportsParserInfo reportsParserInfo = ( ReportsParserInfo) data;
ParamInfo paramInfo = reportsParserInfo.getParamInfo();
Object paramValue = null;
if ( paramInfo != null) {
// 置換する値の取得
paramValue = paramInfo.getParam("$", tagname);
}
//値の設定
PoiUtil.setCellValue(tagCell, paramValue);
//セルの結合
int row = tagCell.getRowIndex();
int col = tagCell.getColumnIndex();
if(rowp>1 || colp>1){ //rowpとcolpは結合するセルのサイズ(1,1なら結合不要)
sheet.addMergedRegion( new CellRangeAddress( row, row+rowp, col, col
+colp));
}
ParsedReportInfo parsedReportInfo = new ParsedReportInfo();
parsedReportInfo.setParsedObject(paramValue); // 置換オブジェクト
parsedReportInfo.setDefaultRowIndex( tagCell.getRowIndex());// 置換前最終行
番号
parsedReportInfo.setDefaultColumnIndex( tagCell.getColumnIndex());//
置換後最終行番号
parsedReportInfo.setRowIndex( tagCell.getRowIndex());// 置換後最終行番号
parsedReportInfo.setColumnIndex( tagCell.getColumnIndex());// 置換後最終行番
号
return parsedReportInfo;
}