Post

Visualizzazione dei post con l'etichetta setCompressTempFiles(true)

Creare file Microsoft Excel .XLS e .XLSX con Apache POI

DOMANDA: In Java è possibile creare un file Microsoft Excel .xls o .xlsx? RISPOSTA: Così come visto per i file Microsoft Word .doc e .docx è possibile creare dei file Microsoft Excel .xls e .xlsx con la libreria gratuita Apache Poi . Guardiamo insieme un esempio: package xsl; import java.io.FileOutputStream; import org.apache.poi.ss.usermodel.Cell; import org.apache.poi.ss.usermodel.Row; import org.apache.poi.ss.usermodel.Sheet; import org.apache.poi.ss.usermodel.Workbook; import org.apache.poi.ss.util.CellReference; import org.apache.poi.xssf.streaming.SXSSFWorkbook; public class XlsApachePoi {    public static void main(String[] args) throws Throwable {       Workbook wb = new SXSSFWorkbook(100); // creo il file (100 righe massimo in memoria)       Sheet sh = wb.createSheet(); // creo un foglio       for ( int numRighe = 0; numRighe < 100; numRighe++){          Row row = sh.createRow(numRighe); // creo una riga          for ( int cell