Ver Mensaje Individual
  #4 (permalink)  
Antiguo 07/06/2012, 17:09
LuisChavezB
 
Fecha de Ingreso: diciembre-2011
Mensajes: 152
Antigüedad: 12 años, 4 meses
Puntos: 34
Respuesta: Exportar resultado de query a Excel

JExcel API ya esta desactualizado y no soporta xlsx, mejor utiliza Jakarta POI:
http://poi.apache.org/trans/es/index.html

Necesitas algunas librerias extra para que funcione:
XMLBeans
Dom4j

Ejemplo:
Código Javascript:
Ver original
  1. try {
  2.             try (DataOutputStream dataOutputStream = new DataOutputStream(new FileOutputStream(new File("D:/example.xlsx")))) {
  3.                 Workbook workbook = new SXSSFWorkbook(-1);
  4.                 Sheet sheet = workbook.createSheet("Hoja 1");
  5.                 sheet.createRow(0).createCell(0).setCellValue(52);
  6.                 workbook.write(dataOutputStream);
  7.                 dataOutputStream.close();
  8.             }
  9.         } catch (IOException ex) {
  10.             Logger.getLogger(ExcelTest.class.getName()).log(Level.SEVERE, null, ex);
  11.         }