Package org.openxml4j.exceptions

Examples of org.openxml4j.exceptions.OpenXML4JException


    // And load it up
    try {
      SAXReader reader = new SAXReader();
      baseDocument = reader.read(basePart.getInputStream());
    } catch (DocumentException e) {
      throw new OpenXML4JException(e.getMessage());
    } catch (IOException ioe) {
      throw new OpenXML4JException(ioe.getMessage());
    }
  }
View Full Code Here


   */
  public boolean marshall(PackagePart part, OutputStream os)
      throws OpenXML4JException {
    if (!(os instanceof ZipOutputStream)) {
      logger.error("Unexpected class " + os.getClass().getName());
      throw new OpenXML4JException("ZipOutputStream expected !");
      // Normally should happen only in developpement phase, so just throw
      // exception
    }

    ZipOutputStream zos = (ZipOutputStream) os;
View Full Code Here

      while(relIter.hasNext()) {
        PackageRelationship rel = relIter.next();
        hyperlinks.add(new XWPFHyperlink(rel.getId(), rel.getTargetURI().toString()));
      }
    } catch(Exception e) {
      throw new OpenXML4JException(e.getLocalizedMessage());
    }

    // Get the comments, if there are any
    PackageRelationshipCollection commentsRel = getCmntRelations();
    if(commentsRel != null && commentsRel.size() > 0) {
View Full Code Here

      if (!StreamHelper.saveXmlInStream(xmlDoc, out)) {
        return false;
      }
      zos.closeEntry();
    } catch (IOException e) {
      throw new OpenXML4JException(e.getLocalizedMessage());
    }
    return true;
  }
View Full Code Here

  public TableCell getCellAt(int line,int col) throws OpenXML4JException {
    //check parameter (col is check in getCell())
    if (line>=lines.size()) {
      String msg="line should be <"+ lines.size()+" line="+line;
      logger.error(msg);
      throw new OpenXML4JException(msg);
    }
//#ifdef JAVA5
    return lines.get(line).getCell(col);
//#else
/*
 
View Full Code Here

    PackagePartName relName =
      PackagingURIHelper.createPartName(rel.getTargetURI());
   
    PackagePart sheet = container.getPart(relName);
    if(sheet == null) {
      throw new OpenXML4JException("No part found for rel " + rel);
    }
    try {
      SAXReader reader = new SAXReader();
      return reader.read(sheet.getInputStream());
    } catch (DocumentException e) {
      throw new OpenXML4JException(e.getMessage());
    } catch (IOException io) {
      throw new OpenXML4JException(io.getMessage());
    }
  }
View Full Code Here

  private void openWorkbook() throws Exception {
    // Find the package part for it
    ArrayList<PackagePart> wbs =
      container.getPartsByContentType(MAIN_CONTENT_TYPE);
    if(wbs.size() != 1) {
      throw new OpenXML4JException("Expecting one entry with content type of " + MAIN_CONTENT_TYPE + ", but found " + wbs.size());
    }
    workbookPart = wbs.get(0);
   
    // And load it up
    try {
      SAXReader reader = new SAXReader();
      workbook = reader.read(workbookPart.getInputStream());
    } catch (DocumentException e) {
      throw new OpenXML4JException(e.getMessage());
    }
  }
View Full Code Here

                .getPartName().getName()) + "'");
        PartMarshaller marshaller = partMarshallers
            .get(part.contentType);
        if (marshaller != null) {
          if (!marshaller.marshall(part, zos)) {
            throw new OpenXML4JException(
                "The part "
                    + part.getPartName().getURI()
                    + " fail to be saved in the stream with marshaller "
                    + marshaller);
          }
        } else {
          if (!defaultPartMarshaller.marshall(part, zos))
            throw new OpenXML4JException(
                "The part "
                    + part.getPartName().getURI()
                    + " fail to be saved in the stream with marshaller "
                    + defaultPartMarshaller);
        }
View Full Code Here

    this.nbCellHorizontallyMerged =1;//no merge
  }

  public CellWidth(int nbCellHorizontallyMerged) throws OpenXML4JException {
    if (nbCellHorizontallyMerged<1) {
      throw new OpenXML4JException("Cell merge should be >= 1");
      // 1 -> no merge, cell is alone
      // 2 -> merge with the next one
      // 3                    2 next ones
    }
    this.nbCellHorizontallyMerged = nbCellHorizontallyMerged;
View Full Code Here

  public TableCell getCell(int col) throws OpenXML4JException {
    if (col>=cells.size()) {
      String msg="col should be <"+ cells.size()+" col="+col;
      logger.error(msg);
      throw new OpenXML4JException(msg);
    }
//#ifdef JAVA5
    return cells.get(col);
//#else
/*
 
View Full Code Here

TOP

Related Classes of org.openxml4j.exceptions.OpenXML4JException

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.