martedì 11 dicembre 2012

Use POI with Excel template

POIFSFileSystem fs = new POIFSFileSystem(      	        new FileInputStream("template.xls"));  HSSFWorkbook wb = new  HSSFWorkbook(fs, true);

Will load an xls, preserving its structure (macros included). You can then modify it,

HSSFSheet sheet1 = wb.getSheet("Data"); ...

and then save it.

FileOutputStream fileOut = new FileOutputStream("new.xls");   wb.write(fileOut);  fileOut.close();

Nessun commento:

Posta un commento