Search in sources :

Example 6 with CTRow

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow in project poi by apache.

the class TestXSSFSheet method groupUngroupRow.

@Test
public void groupUngroupRow() throws IOException {
    XSSFWorkbook workbook = new XSSFWorkbook();
    XSSFSheet sheet = workbook.createSheet();
    //one level
    sheet.groupRow(9, 10);
    assertEquals(2, sheet.getPhysicalNumberOfRows());
    CTRow ctrow = sheet.getRow(9).getCTRow();
    assertNotNull(ctrow);
    assertEquals(10, ctrow.getR());
    assertEquals(1, ctrow.getOutlineLevel());
    assertEquals(1, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow());
    //two level
    sheet.groupRow(10, 13);
    assertEquals(5, sheet.getPhysicalNumberOfRows());
    ctrow = sheet.getRow(10).getCTRow();
    assertNotNull(ctrow);
    assertEquals(11, ctrow.getR());
    assertEquals(2, ctrow.getOutlineLevel());
    assertEquals(2, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow());
    sheet.ungroupRow(8, 10);
    assertEquals(4, sheet.getPhysicalNumberOfRows());
    assertEquals(1, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow());
    sheet.ungroupRow(10, 10);
    assertEquals(3, sheet.getPhysicalNumberOfRows());
    assertEquals(1, sheet.getCTWorksheet().getSheetFormatPr().getOutlineLevelRow());
    workbook.close();
}
Also used : SXSSFWorkbook(org.apache.poi.xssf.streaming.SXSSFWorkbook) CTRow(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow) Test(org.junit.Test)

Example 7 with CTRow

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow in project poi by apache.

the class TestUnfixedBugs method checkRow57423.

private void checkRow57423(Sheet testSheet, int rowNum, String contents) {
    Row row = testSheet.getRow(rowNum);
    assertNotNull("Expecting row at rownum " + rowNum, row);
    CTRow ctRow = ((XSSFRow) row).getCTRow();
    assertEquals(rowNum + 1, ctRow.getR());
    Cell cell = row.getCell(0);
    assertNotNull("Expecting cell at rownum " + rowNum, cell);
    assertEquals("Did not have expected contents at rownum " + rowNum, contents + ".0", cell.toString());
}
Also used : CTRow(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow) Row(org.apache.poi.ss.usermodel.Row) Cell(org.apache.poi.ss.usermodel.Cell) CTRow(org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow)

Example 8 with CTRow

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow in project poi by apache.

the class TestXWPFTable method testCreateRow.

public void testCreateRow() {
    XWPFDocument doc = new XWPFDocument();
    CTTbl table = CTTbl.Factory.newInstance();
    CTRow r1 = table.addNewTr();
    r1.addNewTc().addNewP();
    r1.addNewTc().addNewP();
    CTRow r2 = table.addNewTr();
    r2.addNewTc().addNewP();
    r2.addNewTc().addNewP();
    CTRow r3 = table.addNewTr();
    r3.addNewTc().addNewP();
    r3.addNewTc().addNewP();
    XWPFTable xtab = new XWPFTable(table, doc);
    assertEquals(3, xtab.getNumberOfRows());
    assertNotNull(xtab.getRow(2));
    //add a new row
    xtab.createRow();
    assertEquals(4, xtab.getNumberOfRows());
    //check number of cols
    assertEquals(2, table.getTrArray(0).sizeOfTcArray());
    //check creation of first row
    xtab = new XWPFTable(CTTbl.Factory.newInstance(), doc);
    assertEquals(1, xtab.getCTTbl().getTrArray(0).sizeOfTcArray());
}
Also used : CTTbl(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl) CTRow(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow)

Example 9 with CTRow

use of org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow in project poi by apache.

the class TestXWPFTable method testGetText.

public void testGetText() {
    XWPFDocument doc = new XWPFDocument();
    CTTbl table = CTTbl.Factory.newInstance();
    CTRow row = table.addNewTr();
    CTTc cell = row.addNewTc();
    CTP paragraph = cell.addNewP();
    CTR run = paragraph.addNewR();
    CTText text = run.addNewT();
    text.setStringValue("finally I can write!");
    XWPFTable xtab = new XWPFTable(table, doc);
    assertEquals("finally I can write!\n", xtab.getText());
}
Also used : CTR(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR) CTText(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText) CTTbl(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl) CTRow(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow) CTP(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP) CTTc(org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc)

Aggregations

CTRow (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTRow)6 CTTbl (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTbl)5 XmlCursor (org.apache.xmlbeans.XmlCursor)3 XmlObject (org.apache.xmlbeans.XmlObject)3 CTRow (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTRow)3 SXSSFWorkbook (org.apache.poi.xssf.streaming.SXSSFWorkbook)2 Test (org.junit.Test)2 Cell (org.apache.poi.ss.usermodel.Cell)1 Row (org.apache.poi.ss.usermodel.Row)1 CTCell (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTCell)1 CTSheetData (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTSheetData)1 CTWorksheet (org.openxmlformats.schemas.spreadsheetml.x2006.main.CTWorksheet)1 CTP (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTP)1 CTR (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTR)1 CTTc (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTTc)1 CTText (org.openxmlformats.schemas.wordprocessingml.x2006.main.CTText)1