Cree diferentes tipos de Cell en Apache POI y Aspose.Cells

Aspose.Cells - Crear diferentes tipos Cell

Java

 //Instantiating a Workbook object

Workbook workbook = new Workbook();

//Accessing the added worksheet in the Excel file

Worksheet worksheet = workbook.getWorksheets().get(0);

Cells cells = worksheet.getCells();

//Adding a string value to the cell

Cell cell = cells.get("A1");

cell.setValue("Hello World");

//Adding a double value to the cell

cell = cells.get("A2");

cell.setValue(20.5);

//Adding an integer  value to the cell

cell = cells.get("A3");

cell.setValue(15);

//Adding a boolean value to the cell

cell = cells.get("A4");

cell.setValue(true);

//Adding a date/time value to the cell

cell = cells.get("A5");

cell.setValue(Calendar.getInstance());

//Setting the display format of the date

Style style = cell.getStyle();

style.setNumber(15);

cell.setStyle(style);

Apache POI SS (HSSF + XSSF) - Crear diferentes tipos Cell

Java

 Workbook wb = new HSSFWorkbook();

Sheet sheet = wb.createSheet("new sheet");

Row row = sheet.createRow((short)2);

row.createCell(0).setCellValue(1.1);

row.createCell(1).setCellValue(new Date());

row.createCell(2).setCellValue(Calendar.getInstance());

row.createCell(3).setCellValue("a string");

row.createCell(4).setCellValue(true);

row.createCell(5).setCellType(Cell.CELL_TYPE_ERROR);

Descargar código de ejecución

Descargar ejemplos de ejecución paraCree diferentes tipos de Cell en Aspose.Cells y Apache POI de cualquiera de los sitios de codificación social mencionados a continuación:

Descargar código fuente

Descarga el código fuente deCree diferentes tipos de Cell en Aspose.Cells y Apache POI de cualquiera de los sitios de codificación social mencionados a continuación: