You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@poi.apache.org by bu...@apache.org on 2013/10/25 17:21:52 UTC

[Bug 55705] New: Inserting picture into sheet with chart corrupts workbook

https://issues.apache.org/bugzilla/show_bug.cgi?id=55705

            Bug ID: 55705
           Summary: Inserting picture into sheet with chart corrupts
                    workbook
           Product: POI
           Version: 3.10-dev
          Hardware: PC
            Status: NEW
          Severity: normal
          Priority: P2
         Component: HSSF
          Assignee: dev@poi.apache.org
          Reporter: davnroid@gmail.com

Created attachment 30971
  --> https://issues.apache.org/bugzilla/attachment.cgi?id=30971&action=edit
Test file

When a picture is inserted into sheet that has a chart, resulting file is
corrupted and causes Excel crash in my case.

Code used:

Workbook wb = WorkbookFactory.create(new File("Test_chart.xls"));
InputStream is = new FileInputStream("project-logo.jpg");
byte[] bytes = IOUtils.toByteArray(is);
int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
is.close();

CreationHelper helper = wb.getCreationHelper();
Sheet sheet = wb.getSheetAt(0);
Drawing drawing = sheet.createDrawingPatriarch();
ClientAnchor anchor = helper.createClientAnchor();
anchor.setCol1(10);
anchor.setRow1(2);
anchor.setCol2(13);
anchor.setRow2(8);
drawing.createPicture(anchor, pictureIdx);
String file = "Chart_and_picture.xls";
FileOutputStream fileOut = new FileOutputStream(file);
wb.write(fileOut);
fileOut.close();

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org


[Bug 55705] Inserting picture into sheet with chart corrupts workbook

Posted by bu...@apache.org.
https://issues.apache.org/bugzilla/show_bug.cgi?id=55705

Nick Burch <ap...@gagravarr.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|---                         |WONTFIX
                 OS|                            |All

--- Comment #1 from Nick Burch <ap...@gagravarr.org> ---
From
http://poi.apache.org/apidocs/org/apache/poi/ss/usermodel/Sheet.html#createDrawingPatriarch%28%29

> Note that this will normally have the effect of removing any existing drawings on this sheet.

So, as documented, if you call createDrawingPatriarch on a sheet with existing
drawings/charts, things will break

You'll either need to ensure you only add drawings to sheets without any, or
volunteer to help enhance HSSF to support fetching the existing Drawing to
modify. The latter would be great for everyone, but sadly in many years no-one
has thus far volunteered to help write it / pay someone else to write it :/

-- 
You are receiving this mail because:
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@poi.apache.org
For additional commands, e-mail: dev-help@poi.apache.org