Uploaded image for project: 'XMLBeans'
  1. XMLBeans
  2. XMLBEANS-475

Adding image using XSSF with previous images corrupts the entire file

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Invalid
    • Version 2.3
    • Version 5.0.1
    • None
    • None
    • Windows 7, eclipse, java 1.6

    Description

      When I try to add images to an xlsx file that already contains images, the image is appended as a fragment at the end of the file which causes Microsoft Office to say the file is corrupted and gives the option of trying to recover.

      Workbook workbook = new XSSFWorkbook(doc);
      Sheet sheet;
      if(workbook.getNumberOfSheets() > 0){
      sheet = workbook.getSheetAt(0);
      } else {
      sheet = workbook.createSheet();
      }
      Drawing patriarch = sheet.createDrawingPatriarch();
      ClientAnchor anchor = workbook.getCreationHelper().createClientAnchor();
      anchor.setCol1(10);
      anchor.setRow1(1);
      anchor.setDx1(100);
      anchor.setDy1(190);
      ((XSSFDrawing) patriarch).createLinkedPicture(anchor,"a location");
      workbook.write(outDoc);
      doc.close();
      outDoc.close();

      Attachments

        1. OnePicture.xlsx
          33 kB
          Michael Benoit

        Activity

          People

            Unassigned Unassigned
            datdo Michael Benoit
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: