Package org.apache.poi.xssf.model

Examples of org.apache.poi.xssf.model.Table


     */
    public List<Table> getTables() {
       List<Table> tables = new ArrayList<Table>();
       for(POIXMLDocumentPart p : getRelations()) {
          if (p.getPackageRelationship().getRelationshipType().equals(XSSFRelation.TABLE.getRelation())) {
             Table table = (Table) p;
             tables.add(table);
          }
       }
       return tables;
    }
View Full Code Here


        for (int i = 0; i < sheetNumber; i++) {
            XSSFSheet sheet = mapInfo.getWorkbook().getSheetAt(i);
            for (POIXMLDocumentPart p : sheet.getRelations()) {
                if (p.getPackageRelationship().getRelationshipType().equals(XSSFRelation.TABLE.getRelation())) {
                    Table table = (Table) p;
                    if (table.mapsTo(ctMap.getID())) {
                        tables.add(table);
                    }
                }
            }
        }
View Full Code Here

          Collections.sort(xpaths,this);
         
          for(String xpath : xpaths){
           
              XSSFSingleXmlCell simpleXmlCell = singleXmlCellsMappings.get(xpath);
              Table table = tableMappings.get(xpath);   
             
              if(!xpath.matches(".*\\[.*")){
               
                // Exports elements and attributes mapped with simpleXmlCell
                if(simpleXmlCell!=null){
                  XSSFCell cell = simpleXmlCell.getReferencedCell();
                  if(cell!=null){
                    Node currentNode = getNodeByXPath(xpath,doc.getFirstChild(),doc,false);
                    STXmlDataType.Enum dataType = simpleXmlCell.getXmlDataType();           
                    mapCellOnNode(cell,currentNode,dataType)
                  }
                }
               
                // Exports elements and attributes mapped with tables
                if(table!=null){
                 
                  List<XSSFXmlColumnPr> tableColumns = table.getXmlColumnPrs();
                 
                  XSSFSheet sheet = table.getXSSFSheet();
                 
                  int startRow = table.getStartCellReference().getRow();
                  // In mappings created with Microsoft Excel the first row contains the table header and must be skipped
                  startRow +=1;
                 
                  int endRow = table.getEndCellReference().getRow();
                 
                  for(int i = startRow; i<= endRow; i++){
                    XSSFRow row = sheet.getRow(i);
                   
                    Node tableRootNode = getNodeByXPath(table.getCommonXpath(),doc.getFirstChild(),doc,true);
                   
                    short startColumnIndex = table.getStartCellReference().getCol();
                    for(int j = startColumnIndex; j<= table.getEndCellReference().getCol();j++){
                      XSSFCell cell = row.getCell(j);
                      if(cell!=null){
                        XSSFXmlColumnPr pointer = tableColumns.get(j-startColumnIndex);
                        String localXPath = pointer.getLocalXPath();
                        Node currentNode = getNodeByXPath(localXPath,tableRootNode,doc,false);
View Full Code Here

        Collections.sort(xpaths,this);

        for(String xpath : xpaths) {

            XSSFSingleXmlCell simpleXmlCell = singleXmlCellsMappings.get(xpath);
            Table table = tableMappings.get(xpath);

            if (!xpath.matches(".*\\[.*")) {

                // Exports elements and attributes mapped with simpleXmlCell
                if (simpleXmlCell!=null) {
                    XSSFCell cell = simpleXmlCell.getReferencedCell();
                    if (cell!=null) {
                        Node currentNode = getNodeByXPath(xpath,doc.getFirstChild(),doc,false);
                        STXmlDataType.Enum dataType = simpleXmlCell.getXmlDataType();
                        mapCellOnNode(cell,currentNode,dataType);
                    }
                }

                // Exports elements and attributes mapped with tables
                if (table!=null) {

                    List<XSSFXmlColumnPr> tableColumns = table.getXmlColumnPrs();

                    XSSFSheet sheet = table.getXSSFSheet();

                    int startRow = table.getStartCellReference().getRow();
                    // In mappings created with Microsoft Excel the first row contains the table header and must be skipped
                    startRow +=1;

                    int endRow = table.getEndCellReference().getRow();

                    for(int i = startRow; i<= endRow; i++) {
                        XSSFRow row = sheet.getRow(i);

                        Node tableRootNode = getNodeByXPath(table.getCommonXpath(),doc.getFirstChild(),doc,true);

                        short startColumnIndex = table.getStartCellReference().getCol();
                        for(int j = startColumnIndex; j<= table.getEndCellReference().getCol();j++) {
                            XSSFCell cell = row.getCell(j);
                            if (cell!=null) {
                                XSSFXmlColumnPr pointer = tableColumns.get(j-startColumnIndex);
                                String localXPath = pointer.getLocalXPath();
                                Node currentNode = getNodeByXPath(localXPath,tableRootNode,doc,false);
View Full Code Here

        Collections.sort(xpaths,this);

        for(String xpath : xpaths) {

            XSSFSingleXmlCell simpleXmlCell = singleXmlCellsMappings.get(xpath);
            Table table = tableMappings.get(xpath);

            if (!xpath.matches(".*\\[.*")) {

                // Exports elements and attributes mapped with simpleXmlCell
                if (simpleXmlCell!=null) {
                    XSSFCell cell = simpleXmlCell.getReferencedCell();
                    if (cell!=null) {
                        Node currentNode = getNodeByXPath(xpath,doc.getFirstChild(),doc,false);
                        STXmlDataType.Enum dataType = simpleXmlCell.getXmlDataType();
                        mapCellOnNode(cell,currentNode,dataType);
                    }
                }

                // Exports elements and attributes mapped with tables
                if (table!=null) {

                    List<XSSFXmlColumnPr> tableColumns = table.getXmlColumnPrs();

                    XSSFSheet sheet = table.getXSSFSheet();

                    int startRow = table.getStartCellReference().getRow();
                    // In mappings created with Microsoft Excel the first row contains the table header and must be skipped
                    startRow +=1;

                    int endRow = table.getEndCellReference().getRow();

                    for(int i = startRow; i<= endRow; i++) {
                        XSSFRow row = sheet.getRow(i);

                        Node tableRootNode = getNodeByXPath(table.getCommonXpath(),doc.getFirstChild(),doc,true);

                        short startColumnIndex = table.getStartCellReference().getCol();
                        for(int j = startColumnIndex; j<= table.getEndCellReference().getCol();j++) {
                            XSSFCell cell = row.getCell(j);
                            if (cell!=null) {
                                XSSFXmlColumnPr pointer = tableColumns.get(j-startColumnIndex);
                                String localXPath = pointer.getLocalXPath();
                                Node currentNode = getNodeByXPath(localXPath,tableRootNode,doc,false);
View Full Code Here

        Collections.sort(xpaths,this);

        for(String xpath : xpaths) {

            XSSFSingleXmlCell simpleXmlCell = singleXmlCellsMappings.get(xpath);
            Table table = tableMappings.get(xpath);

            if (!xpath.matches(".*\\[.*")) {

                // Exports elements and attributes mapped with simpleXmlCell
                if (simpleXmlCell!=null) {
                    XSSFCell cell = simpleXmlCell.getReferencedCell();
                    if (cell!=null) {
                        Node currentNode = getNodeByXPath(xpath,doc.getFirstChild(),doc,false);
                        STXmlDataType.Enum dataType = simpleXmlCell.getXmlDataType();
                        mapCellOnNode(cell,currentNode,dataType);
                    }
                }

                // Exports elements and attributes mapped with tables
                if (table!=null) {

                    List<XSSFXmlColumnPr> tableColumns = table.getXmlColumnPrs();

                    XSSFSheet sheet = table.getXSSFSheet();

                    int startRow = table.getStartCellReference().getRow();
                    // In mappings created with Microsoft Excel the first row contains the table header and must be skipped
                    startRow +=1;

                    int endRow = table.getEndCellReference().getRow();

                    for(int i = startRow; i<= endRow; i++) {
                        XSSFRow row = sheet.getRow(i);

                        Node tableRootNode = getNodeByXPath(table.getCommonXpath(),doc.getFirstChild(),doc,true);

                        short startColumnIndex = table.getStartCellReference().getCol();
                        for(int j = startColumnIndex; j<= table.getEndCellReference().getCol();j++) {
                            XSSFCell cell = row.getCell(j);
                            if (cell!=null) {
                                XSSFXmlColumnPr pointer = tableColumns.get(j-startColumnIndex);
                                String localXPath = pointer.getLocalXPath();
                                Node currentNode = getNodeByXPath(localXPath,tableRootNode,doc,false);
View Full Code Here

       XSSFSheet s3 = wb.getSheetAt(2);
       assertEquals(1, s1.getTables().size());
       assertEquals(0, s2.getTables().size());
       assertEquals(0, s3.getTables().size());
      
       Table t = s1.getTables().get(0);
       assertEquals("Tabella1", t.getName());
       assertEquals("Tabella1", t.getDisplayName());
       assertEquals("A1:C3", t.getCTTable().getRef());
      
       // Add a sheet and re-order
       XSSFSheet s4 = wb.createSheet("NewSheet");
       wb.setSheetOrder(s4.getSheetName(), 0);
      
       // Check on tables
       assertEquals(1, s1.getTables().size());
       assertEquals(0, s2.getTables().size());
       assertEquals(0, s3.getTables().size());
       assertEquals(0, s4.getTables().size());
      
       // Refetch to get the new order
       s1 = wb.getSheetAt(0);
       s2 = wb.getSheetAt(1);
       s3 = wb.getSheetAt(2);
       s4 = wb.getSheetAt(3);
       assertEquals(0, s1.getTables().size());
       assertEquals(1, s2.getTables().size());
       assertEquals(0, s3.getTables().size());
       assertEquals(0, s4.getTables().size());
      
       // Save and re-load
       wb = XSSFTestDataSamples.writeOutAndReadBack(wb);
       s1 = wb.getSheetAt(0);
       s2 = wb.getSheetAt(1);
       s3 = wb.getSheetAt(2);
       s4 = wb.getSheetAt(3);
       assertEquals(0, s1.getTables().size());
       assertEquals(1, s2.getTables().size());
       assertEquals(0, s3.getTables().size());
       assertEquals(0, s4.getTables().size());
      
       t = s2.getTables().get(0);
       assertEquals("Tabella1", t.getName());
       assertEquals("Tabella1", t.getDisplayName());
       assertEquals("A1:C3", t.getCTTable().getRef());
    }
View Full Code Here

      
       List<Table> tables = s1.getTables();
       assertNotNull(tables);
       assertEquals(1, tables.size());
      
       Table table = tables.get(0);
       assertEquals("Tabella1", table.getName());
       assertEquals("Tabella1", table.getDisplayName());
      
       // And the others
       XSSFSheet s2 = wb.getSheetAt(1);
       assertEquals(0, s2.getTables().size());
       XSSFSheet s3 = wb.getSheetAt(2);
View Full Code Here

     */
    public List<Table> getTables() {
       List<Table> tables = new ArrayList<Table>();
       for(POIXMLDocumentPart p : getRelations()) {
          if (p.getPackageRelationship().getRelationshipType().equals(XSSFRelation.TABLE.getRelation())) {
             Table table = (Table) p;
             tables.add(table);
          }
       }
       return tables;
    }
View Full Code Here

        for (int i = 0; i < sheetNumber; i++) {
            XSSFSheet sheet = mapInfo.getWorkbook().getSheetAt(i);
            for (POIXMLDocumentPart p : sheet.getRelations()) {
                if (p.getPackageRelationship().getRelationshipType().equals(XSSFRelation.TABLE.getRelation())) {
                    Table table = (Table) p;
                    if (table.mapsTo(ctMap.getID())) {
                        tables.add(table);
                    }
                }
            }
        }
View Full Code Here

TOP

Related Classes of org.apache.poi.xssf.model.Table

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.