なんとなくjavaでexcel

fissplateをいじってみたり。
横展開に縦展開を含めることはできないのか。まぁそりゃそうか。

シートごとに明細帳票みたいな感じで作ろうとして出来なくて断念。
poiとかjxlsとかを直接使ってtemplateとなるシートをリネームしつつ、元のをコピーとかやろうとしたけどうまくいかず。

あ、、、jxlsとjexcelapiは別物か。。。
もっかい試す。

追記。試した。動かん。

ワークブック間でシートをコピーする - azlab 開発Memo
見て「おっ」って思ったんだけどやってみたら動かず。

java.lang.IllegalArgumentException: This Style does not belong to the supplied Workbook. Are you trying to assign a style from one workbook to the cell of a differnt workbook?
at org.apache.poi.hssf.usermodel.HSSFCellStyle.verifyBelongsToWorkbook(HSSFCellStyle.java:996)
at org.apache.poi.hssf.usermodel.HSSFCell.setCellStyle(HSSFCell.java:837)
at net.sf.jxls.util.Util.copyCell(Util.java:514)
at net.sf.jxls.util.Util.copyRow(Util.java:434)
at net.sf.jxls.util.Util.copySheets(Util.java:484)

な感じにstacktraceが出る。

んで、該当コードを見てみると


SourceForge.net Repository - [jxls] View of /jxls/src/java/org/jxls/util/Util.java

411 public static void copyCell(HSSFCell oldCell, HSSFCell newCell, boolean copyStyle) {
412 if( copyStyle ){
413 newCell.setCellStyle(oldCell.getCellStyle());
414 }

[Apache-SVN] Contents of /poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCell.java

885 public void setCellStyle(HSSFCellStyle style) {
886 // Verify it really does belong to our workbook
887 style.verifyBelongsToWorkbook(_book);
888
889 // Change our cell record to use this style
890 _record.setXFIndex(style.getIndex());
891 }

[Apache-SVN] Contents of /poi/trunk/src/java/org/apache/poi/hssf/usermodel/HSSFCellStyle.java

932 /**
933 * Verifies that this style belongs to the supplied Workbook.
934 * Will throw an exception if it belongs to a different one.
935 * This is normally called when trying to assign a style to a
936 * cell, to ensure the cell and the style are from the same
937 * workbook (if they're not, it won't work)
938 * @throws IllegalArgumentException if there's a workbook mis-match
939 */
940 public void verifyBelongsToWorkbook(HSSFWorkbook wb) {
941 if(wb.getWorkbook() != workbook) {
942 throw new IllegalArgumentException("This Style does not belong to the supplied Workbook. Are you trying to assign a style from one workbook to the cell of a differnt workbook?");
943 }
944 }

違うワークブックからのsetStyleは認めていない様子。

むねん。