在Java中将xls转换为xlsx

我使用以下链接中的软件将xls文件转换为xlsx http://www.microsoft.com/en-in/download/details.aspx?id=3

我通过使用java创build一个batch file来运行上述软件。

try { String cmds[] = {batPath}; Runtime runtime = Runtime.getRuntime(); Process process = runtime.exec(cmds); process.getOutputStream().close(); InputStream inputStream = process.getInputStream(); InputStreamReader inputstreamreader = new InputStreamReader(inputStream); BufferedReader bufferedrReader = new BufferedReader(inputstreamreader); String strLine = ""; while ((strLine = bufferedrReader.readLine()) != null) { // System.out.println(strLine); } } catch (IOException ioException) { ioException.printStackTrace(); } 

每次转换器运行时,都会popup一个对话框,表示转换文件…问题是,我可能需要运行100次软件,但是它仍然会干扰其他任何工作,尽pipe我的程序在后台运行。

有没有另外一种方法来做到这一点?

请参阅文章[升级到POI 3.5,包括将现有的HSSF Usermodel代码转换为SS Usermodel(用于XSSF和HSSF)] http://poi.apache.org/spreadsheet/converting.html

这里有一个例子: parsing非常大的Excel 2007文件的最佳语言