ソース読んでたら理解できた(・∀・)
変換できないエラーは多分OpenOfficeがxlsファイルをxlsxファイルに保存できないのが原因だな(´・ω・`)
LibreOfficeではできるのでLibreOffice環境でソース作ってやった(;´Д`)
// LibreOfficeの場所 String libreHome = new File(System.getenv("ProgramFiles"), "LibreOffice 4.0").getPath() // 変換元ファイル File inputFile = new File("ほげ.xls"); // 変換先ファイル File outputFile = new File("ほげ.xlsx"); // xlsxで保存する設定 SimpleDocumentFormatRegistry registry = new SimpleDocumentFormatRegistry(); DocumentFormat xlsx = new DocumentFormat("Microsoft Excel 2007 XML", "xlsx", "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet"); xlsx.setInputFamily(DocumentFamily.SPREADSHEET); xlsx.setStoreProperties(DocumentFamily.SPREADSHEET, Collections.singletonMap("FilterName", "Calc MS Excel 2007 XML")); registry.addFormat(xlsx); // Officeの設定 OfficeManager officeManager = new DefaultOfficeManagerConfiguration() .setOfficeHome(libreHome) .buildOfficeManager(); // 起動 officeManager.start(); OfficeDocumentConverter converter = new OfficeDocumentConverter( officeManager, registry); try { converter.convert(inputFile, outputFile); } finally { officeManager.stop(); }
これでxls→xlsxに変換可能(`・ω・´)シャキーン
JavaのApachi POI で XLSXファイルを作成しようとするとあまりにも遅い時あるからな(´;ω;`)
まぁ65536行以上の場合は諦めるしかない希ガス(;・∀・)
0 件のコメント:
コメントを投稿