You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Daniel Küppers <da...@tetralog.com> on 2017/03/01 14:49:29 UTC
Add hyperlink to picture since 3.14-Beta1
Hi,
before apache poi 3.14-Beta1 i used to connect a picture with a
hyperlink over the XSSFDrawing.addRelation() method.
Example:
XSSFDrawing drawing = row.getSheet().createDrawingPatriarch();
PackageRelationship rel = drawing.getPackagePart().addRelationship(
new URI(myWebsiteTarget), TargetMode.EXTERNAL,
"http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink");
*drawing.addRelation(rel.getId(), new POIXMLDocumentPart());*
CTPictureNonVisual nvPicPr = picture.getCTPicture().getNvPicPr();
CTHyperlink hLinkClick = nvPicPr.getCNvPr().addNewHlinkClick();
hLinkClick.setId(rel.getId());
however, since 3.14-Beta1, it is required to submit a POIXMLRelation zu
the addRelation()-method.
How is it supposed to aquire this? Does anyone else overcome this change?
I couldn't find something related in the patchnotes either.
kind regards, Daniel
Re: Add hyperlink to picture since 3.14-Beta1
Posted by Dominik Stadler <do...@gmx.at>.
Hi,
something like the following makes it run, although I am not sure if this
is doing the right thing here
POIXMLDocumentPart part = new POIXMLDocumentPart(new
MemoryPackagePart(new ZipPackage(),
PackagingURIHelper.createPartName("/sample/name"), "image/png"));
drawing.addRelation(rel.getId(), XSSFRelation.SHEET_HYPERLINKS, part);
Regards.. Dominik.
On Mon, Mar 6, 2017 at 3:46 PM, Daniel Küppers <da...@tetralog.com> wrote:
> Hi Dominik,
>
> i tried that in a previous approach, but no luck. This throws a
> NullPointerException.
>
> regards, Daniel
>
> Am 05.03.2017 um 22:37 schrieb Dominik Stadler:
>
> Hi,
>
> I don't know much about all this, but XSSFRelation seems to contain
> constants for a number of types, one of them HYPERLINK, so it seems you can
> use something like:
>
> drawing.addRelation(rel.getId(), XSLFRelation.HYPERLINK, new
> POIXMLDocumentPart());
>
> Dominik.
>
> On Wed, Mar 1, 2017 at 3:49 PM, Daniel Küppers <da...@tetralog.com> <da...@tetralog.com> wrote:
>
>
> Hi,
> before apache poi 3.14-Beta1 i used to connect a picture with a hyperlink
> over the XSSFDrawing.addRelation() method.
> Example:
> XSSFDrawing drawing = row.getSheet().createDrawingPatriarch();
> PackageRelationship rel = drawing.getPackagePart().addRelationship(
> new URI(myWebsiteTarget), TargetMode.EXTERNAL, "
> http://schemas.openxmlformats.org/officeDocument/2006/relat
> ionships/hyperlink" <http://schemas.openxmlformats.org/officeDocument/2006/relationships/hyperlink>);
> *drawing.addRelation(rel.getId(), new POIXMLDocumentPart());*
> CTPictureNonVisual nvPicPr = picture.getCTPicture().getNvPicPr();
> CTHyperlink hLinkClick = nvPicPr.getCNvPr().addNewHlinkClick();
> hLinkClick.setId(rel.getId());
>
> however, since 3.14-Beta1, it is required to submit a POIXMLRelation zu
> the addRelation()-method.
> How is it supposed to aquire this? Does anyone else overcome this change?
> I couldn't find something related in the patchnotes either.
>
> kind regards, Daniel
>
>
>
> --
> Mit freundlichen Gruessen / Kind regards
> gez. / signed *Daniel Küppers* (Developer)
> *TETRALOG* - Kunststoffrecycling e.K.
> Am Muensterwald 1, D - 52159 Roetgen, GERMANY
> phone/Tel.: +49 - 2471 - 133 70 - 13 <+49%202471%201337013> / fax: - 29
> Amtsgericht Aachen, HRA 4627
> www.tetralog.com
> [image: Tetralog Logo]
>
Re: Add hyperlink to picture since 3.14-Beta1
Posted by Daniel Küppers <da...@tetralog.com>.
Hi Dominik,
i tried that in a previous approach, but no luck. This throws a
NullPointerException.
regards, Daniel
Am 05.03.2017 um 22:37 schrieb Dominik Stadler:
> Hi,
>
> I don't know much about all this, but XSSFRelation seems to contain
> constants for a number of types, one of them HYPERLINK, so it seems you can
> use something like:
>
> drawing.addRelation(rel.getId(), XSLFRelation.HYPERLINK, new
> POIXMLDocumentPart());
>
> Dominik.
>
> On Wed, Mar 1, 2017 at 3:49 PM, Daniel K�ppers <da...@tetralog.com> wrote:
>
>> Hi,
>> before apache poi 3.14-Beta1 i used to connect a picture with a hyperlink
>> over the XSSFDrawing.addRelation() method.
>> Example:
>> XSSFDrawing drawing = row.getSheet().createDrawingPatriarch();
>> PackageRelationship rel = drawing.getPackagePart().addRelationship(
>> new URI(myWebsiteTarget), TargetMode.EXTERNAL, "
>> http://schemas.openxmlformats.org/officeDocument/2006/relat
>> ionships/hyperlink");
>> *drawing.addRelation(rel.getId(), new POIXMLDocumentPart());*
>> CTPictureNonVisual nvPicPr = picture.getCTPicture().getNvPicPr();
>> CTHyperlink hLinkClick = nvPicPr.getCNvPr().addNewHlinkClick();
>> hLinkClick.setId(rel.getId());
>>
>> however, since 3.14-Beta1, it is required to submit a POIXMLRelation zu
>> the addRelation()-method.
>> How is it supposed to aquire this? Does anyone else overcome this change?
>> I couldn't find something related in the patchnotes either.
>>
>> kind regards, Daniel
>>
--
Mit freundlichen Gruessen / Kind regards
gez. / signed *Daniel K�ppers* (Developer)
*TETRALOG* - Kunststoffrecycling e.K.
Am Muensterwald 1, D - 52159 Roetgen, GERMANY
phone/Tel.: +49 - 2471 - 133 70 - 13 / fax: - 29
Amtsgericht Aachen, HRA 4627
www.tetralog.com
Tetralog Logo
Re: Add hyperlink to picture since 3.14-Beta1
Posted by Dominik Stadler <do...@gmx.at>.
Hi,
I don't know much about all this, but XSSFRelation seems to contain
constants for a number of types, one of them HYPERLINK, so it seems you can
use something like:
drawing.addRelation(rel.getId(), XSLFRelation.HYPERLINK, new
POIXMLDocumentPart());
Dominik.
On Wed, Mar 1, 2017 at 3:49 PM, Daniel Küppers <da...@tetralog.com> wrote:
> Hi,
> before apache poi 3.14-Beta1 i used to connect a picture with a hyperlink
> over the XSSFDrawing.addRelation() method.
> Example:
> XSSFDrawing drawing = row.getSheet().createDrawingPatriarch();
> PackageRelationship rel = drawing.getPackagePart().addRelationship(
> new URI(myWebsiteTarget), TargetMode.EXTERNAL, "
> http://schemas.openxmlformats.org/officeDocument/2006/relat
> ionships/hyperlink");
> *drawing.addRelation(rel.getId(), new POIXMLDocumentPart());*
> CTPictureNonVisual nvPicPr = picture.getCTPicture().getNvPicPr();
> CTHyperlink hLinkClick = nvPicPr.getCNvPr().addNewHlinkClick();
> hLinkClick.setId(rel.getId());
>
> however, since 3.14-Beta1, it is required to submit a POIXMLRelation zu
> the addRelation()-method.
> How is it supposed to aquire this? Does anyone else overcome this change?
> I couldn't find something related in the patchnotes either.
>
> kind regards, Daniel
>