POI 3.9 新特性 Cover, 可直接將excel 2003 文件 轉換成 html 文件, 不用再一一分析處理。html
固然,方便的同時也有弊端,那就是格式固定,處理多sheet時兼容性很差。bash
try { Document doc = ExcelToHtmlConverter.process( new File( args[0] ) ); FileWriter out = new FileWriter( args[1] ); DOMSource domSource = new DOMSource( doc ); StreamResult streamResult = new StreamResult( out ); TransformerFactory tf = TransformerFactory.newInstance(); Transformer serializer = tf.newTransformer(); // TODO set encoding from a command argument serializer.setOutputProperty( OutputKeys.ENCODING, "UTF-8" ); serializer.setOutputProperty( OutputKeys.INDENT, "no" ); serializer.setOutputProperty( OutputKeys.METHOD, "html" ); serializer.transform( domSource, streamResult ); out.close(); }