Example usage for org.apache.poi.ss.usermodel Sheet createRow

List of usage examples for org.apache.poi.ss.usermodel Sheet createRow

Introduction

In this page you can find the example usage for org.apache.poi.ss.usermodel Sheet createRow.

Prototype

Row createRow(int rownum);

Source Link

Document

Create a new row within the sheet and return the high level representation

Usage

From source file:cherry.goods.excel.ExcelReaderTest.java

License:Apache License

@Test
public void testRead_BLANK() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // /*from w  w  w .java 2s.  co m*/
        Sheet sheet = workbook.createSheet();
        Row row0 = sheet.createRow(0);
        row0.createCell(0);
        row0.createCell(1);

        // 
        try (ExcelReader reader = new ExcelReader(workbook)) {

            String[] r0 = reader.read();
            assertNotNull(r0);
            assertEquals(2, r0.length);
            assertEquals("", r0[0]);
            assertEquals("", r0[1]);

            assertNull(reader.read());
        }
    }
}

From source file:cherry.goods.excel.ExcelReaderTest.java

License:Apache License

@Test
public void testRead_BOOLEAN() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // //w  w w.  j  a  va2s .c  o  m
        Sheet sheet = workbook.createSheet();
        Row row0 = sheet.createRow(0);
        row0.createCell(0).setCellValue(true);
        row0.createCell(1).setCellValue(false);

        // 
        try (ExcelReader reader = new ExcelReader(workbook)) {

            String[] r0 = reader.read();
            assertNotNull(r0);
            assertEquals(2, r0.length);
            assertEquals("true", r0[0]);
            assertEquals("false", r0[1]);

            assertNull(reader.read());
        }
    }
}

From source file:cherry.goods.excel.ExcelReaderTest.java

License:Apache License

@Test
public void testRead_ERROR() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // /*from   www.  j  av  a  2s . c o  m*/
        Sheet sheet = workbook.createSheet();
        Row row0 = sheet.createRow(0);
        row0.createCell(0).setCellErrorValue((byte) 0);
        row0.createCell(1).setCellErrorValue((byte) 0);

        // 
        try (ExcelReader reader = new ExcelReader(workbook)) {

            String[] r0 = reader.read();
            assertNotNull(r0);
            assertEquals(2, r0.length);
            assertNull(r0[0]);
            assertNull(r0[1]);

            assertNull(reader.read());
        }
    }
}

From source file:cherry.goods.excel.ExcelReaderTest.java

License:Apache License

@Test
public void testRead_FORMULA_NUMERIC() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // //  www .  j av a2  s .c o m
        Sheet sheet = workbook.createSheet();
        Row row0 = sheet.createRow(0);
        row0.createCell(0).setCellFormula("1200+34");
        row0.createCell(1).setCellFormula("1200+34.56");
        FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
        evaluator.evaluateAll();

        // 
        try (ExcelReader reader = new ExcelReader(workbook)) {

            String[] r0 = reader.read();
            assertNotNull(r0);
            assertEquals(2, r0.length);
            assertEquals("1234", r0[0]);
            assertEquals("1234.56", r0[1]);

            assertNull(reader.read());
        }
    }
}

From source file:cherry.goods.excel.ExcelReaderTest.java

License:Apache License

@Test
public void testRead_FORMULA_STRING() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // // w  w  w.  ja v a 2s .  c  o m
        Sheet sheet = workbook.createSheet();
        Row row0 = sheet.createRow(0);
        row0.createCell(0).setCellFormula("\"CELL\"&\"00\"");
        row0.createCell(1).setCellFormula("\"CELL\"&\"01\"");
        FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
        evaluator.evaluateAll();

        // 
        try (ExcelReader reader = new ExcelReader(workbook)) {

            String[] r0 = reader.read();
            assertNotNull(r0);
            assertEquals(2, r0.length);
            assertEquals("CELL00", r0[0]);
            assertEquals("CELL01", r0[1]);

            assertNull(reader.read());
        }
    }
}

From source file:cherry.goods.excel.ExcelReaderTest.java

License:Apache License

@Test
public void testRead_FORMULA_BOOLEAN() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // /*from  w w w . j  a  va2 s.c  o m*/
        Sheet sheet = workbook.createSheet();
        Row row0 = sheet.createRow(0);
        row0.createCell(0).setCellFormula("1=1");
        row0.createCell(1).setCellFormula("1=0");
        FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
        evaluator.evaluateAll();

        // 
        try (ExcelReader reader = new ExcelReader(workbook)) {

            String[] r0 = reader.read();
            assertNotNull(r0);
            assertEquals(2, r0.length);
            assertEquals("true", r0[0]);
            assertEquals("false", r0[1]);

            assertNull(reader.read());
        }
    }
}

From source file:cherry.goods.excel.ExcelReaderTest.java

License:Apache License

@Test
public void testRead_FORMULA_ERROR() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // /*from w w w  .  ja va2  s .c  o m*/
        Sheet sheet = workbook.createSheet();
        Row row0 = sheet.createRow(0);
        row0.createCell(0).setCellErrorValue((byte) 0);
        row0.createCell(1).setCellFormula("A1");
        FormulaEvaluator evaluator = workbook.getCreationHelper().createFormulaEvaluator();
        evaluator.evaluateAll();

        // 
        try (ExcelReader reader = new ExcelReader(workbook)) {

            String[] r0 = reader.read();
            assertNotNull(r0);
            assertEquals(2, r0.length);
            assertNull(r0[0]);
            assertNull(r0[1]);

            assertNull(reader.read());
        }
    }
}

From source file:cherry.goods.excel.ExcelWriterTest.java

License:Apache License

@Test
public void testWrite_2_COLS_2_ROWS_WITH_NULL() throws IOException {
    try (Workbook workbook = new XSSFWorkbook()) {
        // /*  ww  w .j av  a 2s.c o  m*/
        Sheet sheet = workbook.createSheet("CREATED 0");
        Row row0 = sheet.createRow(0);
        row0.createCell(0);
        row0.createCell(1);

        // 
        try (ExcelWriter writer = new ExcelWriter(workbook)) {
            writer.write("CELL 00", null);
            writer.write(null, "CELL 11");

            assertEquals("CELL 00", sheet.getRow(0).getCell(0).getStringCellValue());
            assertNull(sheet.getRow(0).getCell(1));
            assertNull(sheet.getRow(1).getCell(0));
            assertEquals("CELL 11", sheet.getRow(1).getCell(1).getStringCellValue());
        }
    }
}

From source file:chronostone.parser.ChronoStoneParser.java

private static void inicializar_celdas(Sheet hoja) {
    Row fila = hoja.createRow(xls_index);
    xls_index++;//from w  w w  .  ja v a 2s  .c  o m
    Cell celda = fila.createCell(0);
    celda.setCellValue("Name");
    celda = fila.createCell(1);
    celda.setCellValue("Position");
    celda = fila.createCell(2);
    celda.setCellValue(gp);
    celda = fila.createCell(3);
    celda.setCellValue(TP);
    celda = fila.createCell(4);
    celda.setCellValue(KICK);
    celda = fila.createCell(5);
    celda.setCellValue(DRIBBLING);
    celda = fila.createCell(6);
    celda.setCellValue(BLOCK);
    celda = fila.createCell(7);
    celda.setCellValue(A_CATCH);
    celda = fila.createCell(8);
    celda.setCellValue(TECHNIQUE);
    celda = fila.createCell(9);
    celda.setCellValue(SPEED);
    celda = fila.createCell(10);
    celda.setCellValue(STAMINA);
    celda = fila.createCell(11);
    celda.setCellValue(LUCKY);
}

From source file:chronostone.parser.ChronoStoneParser.java

private static void add_character_sheet(Sheet hoja) {
    Row fila = hoja.createRow(xls_index);
    xls_index++;/*  ww w  .j av a2s.  c  o m*/
    Cell celda = fila.createCell(0);
    celda.setCellValue(tenmakun.getName());
    celda = fila.createCell(1);
    celda.setCellValue(tenmakun.getPosition());
    celda = fila.createCell(2);
    celda.setCellValue(tenmakun.getGp());
    celda = fila.createCell(3);
    celda.setCellValue(tenmakun.getTp());
    celda = fila.createCell(4);
    celda.setCellValue(tenmakun.getKick());
    celda = fila.createCell(5);
    celda.setCellValue(tenmakun.getDribbling());
    celda = fila.createCell(6);
    celda.setCellValue(tenmakun.getBlock());
    celda = fila.createCell(7);
    celda.setCellValue(tenmakun.getCatch_keeper());
    celda = fila.createCell(8);
    celda.setCellValue(tenmakun.getTechnique());
    celda = fila.createCell(9);
    celda.setCellValue(tenmakun.getSpeed());
    celda = fila.createCell(10);
    celda.setCellValue(tenmakun.getStamina());
    celda = fila.createCell(11);
    celda.setCellValue(tenmakun.getLucky());
}