POI生成的*.xlsx文件无法读取,请高手指点!
代码如下,仅仅是在读入*.xltx模版文件时,再写成的*.xlsx文件无法读取。
请高手指点!
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
public class T2 {
/**
* @param args
* @throws IOException
* @throws InvalidFormatException
*/
public static void main(String[] args) throws InvalidFormatException,
IOException {
FileInputStream fis = new FileInputStream("E:\\t.xltx");
// 创建一个工作薄
Workbook wb = new XSSFWorkbook(fis);
FileOutputStream fileOut;
try {
fileOut = new FileOutputStream("E://xssf.xlsx");
wb.write(fileOut);
fileOut.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}