You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Philip Gillissen <ph...@bayer.com> on 2012/03/28 10:44:45 UTC
Excel 2010 warns of POI created file with embedded graphics
Hello POI users,
I'm currently developing an Excel report with Apache POI 3.8 and I have a small problem with the produced XLS files.
It contains graphics (PNG) and Microsoft Office 2010 warns me about the unsecure content.
[cid:image001.png@01CD0CCF.CA48E1B0]
In English, the warning is called "Protected View" and looks like this:
http://officeimg.vo.msecnd.net/en-us/files/763/533/ZA010388955.jpg
If I don't embed the graphics, Excel does not warn me.
I would like to know if there's a way to embed PNG graphics into an XLS without forcing Microsoft Excel 2010 to open it in the protected view.
Thanks in advance for all hints.
Best Regards
Philip Gillißen
_________________________________________
Bayer Business Services GmbH
51368 Leverkusen, Deutschland
BBS-S&T-APS-Application Development
Leverkusen, 4810
Büro: 1.02
Tel: +49 214 30 49436
E-Mail: philip.gillissen@bayer.com<ma...@bayer.com>
Web: http://www.BayerBBS.com
Geschäftsführung: Vorsitzender Daniel Hartert | Norbert Fieseler
Vorsitzender des Aufsichtsrats: Werner Baumann
Sitz der Gesellschaft: Leverkusen | Amtsgericht Köln, HRB 49895
AW: Excel 2010 warns of POI created file with embedded graphics
Posted by Philip Gillissen <ph...@bayer.com>.
Hello!
I solved my problem with a very lucky coincidence.
My application created the image via the following code:
byte[] tmpImageBytes = ;//Magic
int tmpPictureIdx = tempWorkBook.addPicture(tmpImageBytes, HSSFWorkbook.PICTURE_TYPE_PNG);
short tmpX = ; //Magic
HSSFClientAnchor tmpAnchor = new HSSFClientAnchor(1, 2, IMAGE_WIDTH, IMAGE_HEIGHT, tmpX, tmpY, tmpX, tmpY);
tmpAnchor.setAnchorType(ANCHOR_TYPE_DONT_MOVE_DONT_SIZE);
HSSFShapeGroup tmpShapeGroup = tmpPatriarch.createGroup(tmpAnchor);
tmpShapeGroup.setCoordinates(0, 0, 200, 20);
tmpPatriarch.createPicture(tmpAnchor, tmpPictureIdx);
I saw the tutorial for Busy Developers on the POI site and there, the image is created by the following code (adapted to my application):
CreationHelper tmpHelper = tempWorkBook.getCreationHelper();
byte[] tmpImageBytes = ;//Magic
int tmpPictureIdx = tempWorkBook.addPicture(tmpImageBytes, HSSFWorkbook.PICTURE_TYPE_PNG);
short tmpX = (short) tempColumnCount;
ClientAnchor tmpAnchor = tmpHelper.createClientAnchor();
tmpAnchor.setCol1(tmpX);
tmpAnchor.setRow1(tmpY);
HSSFPicture tmpPicture = tmpPatriarch.createPicture(tmpAnchor, tmpPictureIdx);
The Helper class creates the image perfectly and Office 2010 does not open the xls in the protected view.
I hope, this helps someone :)
Mit freundlichen Grüßen / Best Regards
Philip Gillißen
_________________________________________
Bayer Business Services GmbH
51368 Leverkusen, Deutschland
BBS-S&T-APS-Application Development
Leverkusen, 4810
Büro: 1.02
Tel: +49 214 30 49436
E-Mail: philip.gillissen@bayer.com<ma...@bayer.com>
Web: http://www.BayerBBS.com
Geschäftsführung: Vorsitzender Daniel Hartert | Norbert Fieseler
Vorsitzender des Aufsichtsrats: Werner Baumann
Sitz der Gesellschaft: Leverkusen | Amtsgericht Köln, HRB 49895
Von: Philip Gillissen
Gesendet: Mittwoch, 28. März 2012 10:45
An: user@poi.apache.org
Betreff: Excel 2010 warns of POI created file with embedded graphics
Hello POI users,
I'm currently developing an Excel report with Apache POI 3.8 and I have a small problem with the produced XLS files.
It contains graphics (PNG) and Microsoft Office 2010 warns me about the unsecure content.
[cid:image001.png@01CD0CCF.CA48E1B0]
In English, the warning is called "Protected View" and looks like this:
http://officeimg.vo.msecnd.net/en-us/files/763/533/ZA010388955.jpg
If I don't embed the graphics, Excel does not warn me.
I would like to know if there's a way to embed PNG graphics into an XLS without forcing Microsoft Excel 2010 to open it in the protected view.
Thanks in advance for all hints.
Best Regards
Philip Gillißen
_________________________________________
Bayer Business Services GmbH
51368 Leverkusen, Deutschland
BBS-S&T-APS-Application Development
Leverkusen, 4810
Büro: 1.02
Tel: +49 214 30 49436
E-Mail: philip.gillissen@bayer.com<ma...@bayer.com>
Web: http://www.BayerBBS.com
Geschäftsführung: Vorsitzender Daniel Hartert | Norbert Fieseler
Vorsitzender des Aufsichtsrats: Werner Baumann
Sitz der Gesellschaft: Leverkusen | Amtsgericht Köln, HRB 49895