Package org.docx4j.openpackaging.parts.SpreadsheetML

Examples of org.docx4j.openpackaging.parts.SpreadsheetML.WorksheetPart


    while(it.hasNext()) {
      Map.Entry<PartName, Part> pairs = it.next();
     
      if (partsMap.get(pairs.getKey()) instanceof WorksheetPart) {
       
        WorksheetPart wsp = (WorksheetPart) partsMap.get(pairs.getKey()) ;
       
        List<Row> rows = wsp.getJaxbElement().getSheetData().getRow();

        for (Row row : rows) {
          List<Cell> cells = row.getC();
          for (Cell cell : cells)
          {
View Full Code Here


 
    String outputfilepath = System.getProperty("user.dir") + "/OUT_Xlsx4JAddImage.xlsx";
    String imagefilePath = System.getProperty("user.dir")+"/src/test/resources/images/greentick.png" ;
   
    SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
    WorksheetPart worksheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1);

    // Create Drawing part and add to sheet
    Drawing drawingPart = new Drawing();
    Relationship drawingRel = worksheet.addTargetPart(drawingPart);

    // Add anchor XML to worksheet
    org.xlsx4j.sml.CTDrawing drawing = org.xlsx4j.jaxb.Context.getsmlObjectFactory().createCTDrawing();
        worksheet.getJaxbElement().setDrawing(drawing);
            drawing.setId( drawingRel.getId() );    
   
    // Create image part and add to Drawing part
        BinaryPartAbstractImage imagePart
          = BinaryPartAbstractImage.createImagePart(pkg, drawingPart,
View Full Code Here

   */
  public WorksheetPart createWorksheetPart(PartName partName,
      String sheetName, long sheetId)
    throws InvalidFormatException, JAXBException {
   
    WorksheetPart worksheetPart = new WorksheetPart(partName);
   
    Relationship r = wb.addTargetPart(worksheetPart);
   
    Sheets sheets = wb.getJaxbElement().getSheets();
   
    Sheet s = Context.getsmlObjectFactory().createSheet();
    s.setName(sheetName);
    s.setId(r.getId());
    s.setSheetId(sheetId);
   
    sheets.getSheet().add(s);
   
    // minimal content for the part
    Worksheet ws = Context.getsmlObjectFactory().createWorksheet();
    worksheetPart.setJaxbElement(ws);
    ws.setSheetData(
        Context.getsmlObjectFactory().createSheetData()
        );
   
    return worksheetPart;
View Full Code Here

              String outputfilepath = System.getProperty("user.dir") + "/OUT_XlsxAddComment.xlsx";

              SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();

              WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1);
              addContent(sheet);

              pkg.save(new File(outputfilepath));

              System.out.println("\n\n done .. " + outputfilepath);  
View Full Code Here

   */
  public static void main(String[] args) throws JAXBException, Docx4JException {
    // TODO Auto-generated method stub
    SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
       
    WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/sheet1.xml"), "Sheet1", 1);
         
    CTSheetFormatPr format = Context.getsmlObjectFactory().createCTSheetFormatPr();
    format.setDefaultRowHeight(5);
    format.setCustomHeight(Boolean.TRUE);
    sheet.getJaxbElement().setSheetFormatPr(format);
         
    SheetData sheetData = sheet.getJaxbElement().getSheetData();
               
    Row row = Context.getsmlObjectFactory().createRow();
         
    row.setHt(66.0);
    row.setCustomHeight(Boolean.TRUE);
View Full Code Here

 
    String outputfilepath = System.getProperty("user.dir") + "/OUT_CreateSimpleSpreadsheet.xlsx";
   
    SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
   
    WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1);
   
    addContent(sheet);
   
    SaveToZipFile saver = new SaveToZipFile(pkg);
    saver.save(outputfilepath);
View Full Code Here

            newCell.setR(newRef.toReference());

            newRow.getC().add(newCell);
            newCell.setParent(newRow);

            WorksheetPart worksheetPart = null;
            for (Document.SheetWrapper sheetWrapper : result.getWorksheets()) {
                if (sheetWrapper.getWorksheet().getJaxbElement() == resultWorksheet) {
                    worksheetPart = sheetWrapper.getWorksheet();
                }
            }
View Full Code Here

   
    String outputfilepath = "data/xlsx4j/newWorksheet_Xlsx4j.xlsx";
   
    SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
   
    WorksheetPart sheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1);
   
    addContent(sheet);
   
    SaveToZipFile saver = new SaveToZipFile(pkg);
    saver.save(outputfilepath);
View Full Code Here

    while(it.hasNext()) {
      Map.Entry<PartName, Part> pairs = it.next();
     
      if (partsMap.get(pairs.getKey()) instanceof WorksheetPart) {
       
        WorksheetPart wsp = (WorksheetPart) partsMap.get(pairs.getKey()) ;
       
        List<Row> rows = wsp.getJaxbElement().getSheetData().getRow();

        for (Row row : rows) {
          List<Cell> cells = row.getC();
          for (Cell cell : cells)
          {
View Full Code Here

   
    String outputfilepath = System.getProperty("user.dir") + "/data/xlsx4j/AddImage-Xlsx4j.xlsx";
    String imagefilePath  = System.getProperty("user.dir") + "/data/xlsx4j/greentick.png" ;
   
    SpreadsheetMLPackage pkg = SpreadsheetMLPackage.createPackage();
    WorksheetPart worksheet = pkg.createWorksheetPart(new PartName("/xl/worksheets/sheet1.xml"), "Sheet1", 1);

    // Create Drawing part and add to sheet
    Drawing drawingPart = new Drawing();
    Relationship drawingRel = worksheet.addTargetPart(drawingPart);

    // Add anchor XML to worksheet
    org.xlsx4j.sml.CTDrawing drawing = org.xlsx4j.jaxb.Context.getsmlObjectFactory().createCTDrawing();
        worksheet.getJaxbElement().setDrawing(drawing);
            drawing.setId( drawingRel.getId() );    
   
    // Create image part and add to Drawing part
        BinaryPartAbstractImage imagePart
          = BinaryPartAbstractImage.createImagePart(pkg, drawingPart,
View Full Code Here

TOP

Related Classes of org.docx4j.openpackaging.parts.SpreadsheetML.WorksheetPart

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.