I am creating export files with Apache POI (as .xls so far) with this code successfully
Connection conn = ...// get database connection in some way
Map beans = new HashMap();
ReportManager rm = new ReportManagerImpl( conn, beans );
beans.put("rm", rm);
InputStream is =
new BufferedInputStream(new FileInputStream("reportTemplate.xls"));
XLSTransformer transformer = new XLSTransformer();
HSSFWorkbook resultWorkbook = transformer.transformXLS(is, beans);
retrieved from here. But now my question is: is there a possibility to get the exact same thing for .xlsx? I am not able to find anything on the web concerning this, but it would surprise me if I am the first one needing this.
You should upgrade your jXLS. Support for .xlsx files was added in version 1.0, according to the project's news page. The current version of jXLS is 1.0.2 and it has the transformXLS
method returning a Workbook
object, not a HSSFWorkbook
.
public org.apache.poi.ss.usermodel.Workbook transformXLS(
InputStream is, Map beanParams)