You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by harshask <hs...@gmail.com> on 2012/08/02 13:21:05 UTC

Problem while inserting image multiple times in a worksheet

Hi,

i used the below code to display image in my excel worksheet.
        
try {
            HSSFClientAnchor anchor =
                new HSSFClientAnchor(0, 0, 255, 255, (short)colNo, rowNo,
                                     (short)++colNo, rowNo);
            int index = wb.addPicture(bytes,
HSSFWorkbook.PICTURE_TYPE_JPEG);
            HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
            patriarch.createPicture(anchor, index);
            anchor.setAnchorType(2);
        } catch (Exception e) {
            e.printStackTrace();
        }

Image is displayed only once, in the place where its executed last.

I read in a blog that, HSSFPatriarch patriarch =
sheet.createDrawingPatriarch(); removes all the existing shapes in the work
sheet. How can i display the same image many times in a single worksheet?

Thank you,
Harsha




--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588.html
Sent from the POI - User mailing list archive at Nabble.com.

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


Re: Problem while inserting image multiple times in a worksheet

Posted by harshask <hs...@gmail.com>.
Thank you for the information. Is there a way in POI to insert image into
excel header???

On Thu, Aug 2, 2012 at 6:12 PM, Yegor Kozlov-4 [via Apache POI] <
ml-node+s1045710n5710594h74@n5.nabble.com> wrote:

> There is a ongoing effort to impove drawing support in HSSF, we hope
> to check min these changes in two or three weeks.
> Stay with POI and try a build from trunk after that.
>
> Yegor
>
> On Thu, Aug 2, 2012 at 4:14 PM, harshask <[hidden email]<http://user/SendEmail.jtp?type=node&node=5710594&i=0>>
> wrote:
>
> >  I am modifying a template Sir.
> >
> > On Thu, Aug 2, 2012 at 5:34 PM, Yegor Kozlov-4 [via Apache POI] <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=5710594&i=1>>
> wrote:
> >
> >> Are  you creating a workbook from scratch or modiying a template ?
> >>
> >>
> >> On Thu, Aug 2, 2012 at 3:21 PM, harshask <[hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710591&i=0>>
> >> wrote:
> >>
> >> > Hi,
> >> >
> >> > i used the below code to display image in my excel worksheet.
> >> >
> >> > try {
> >> >             HSSFClientAnchor anchor =
> >> >                 new HSSFClientAnchor(0, 0, 255, 255, (short)colNo,
> >> rowNo,
> >> >                                      (short)++colNo, rowNo);
> >> >             int index = wb.addPicture(bytes,
> >> > HSSFWorkbook.PICTURE_TYPE_JPEG);
> >> >             HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> >> >             patriarch.createPicture(anchor, index);
> >> >             anchor.setAnchorType(2);
> >> >         } catch (Exception e) {
> >> >             e.printStackTrace();
> >> >         }
> >> >
> >> > Image is displayed only once, in the place where its executed last.
> >> >
> >> > I read in a blog that, HSSFPatriarch patriarch =
> >> > sheet.createDrawingPatriarch(); removes all the existing shapes in
> the
> >> work
> >> > sheet. How can i display the same image many times in a single
> >> worksheet?
> >> >
> >> > Thank you,
> >> > Harsha
> >> >
> >> >
> >> >
> >> >
> >> > --
> >> > View this message in context:
> >>
> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588.html
> >> > Sent from the POI - User mailing list archive at Nabble.com.
> >> >
> >> > ---------------------------------------------------------------------
> >> > To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710591&i=1>
> >> > For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710591&i=2>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710591&i=3>
> >> For additional commands, e-mail: [hidden email]<
> http://user/SendEmail.jtp?type=node&node=5710591&i=4>
> >>
> >>
> >>
> >> ------------------------------
> >>  If you reply to this email, your message will be added to the
> discussion
> >> below:
> >>
> >>
> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710591.html
> >>  To unsubscribe from Problem while inserting image multiple times in a
> >> worksheet, click here<
>
> >> .
> >> NAML<
> http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
> >>
> >
> >
> >
> >
> > --
> > View this message in context:
> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710592.html
>
> > Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710594&i=2>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710594&i=3>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710594.html
>  To unsubscribe from Problem while inserting image multiple times in a
> worksheet, click here<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5710588&code=aHNrLjE5ODhAZ21haWwuY29tfDU3MTA1ODh8OTA4NTg2NDU=>
> .
> NAML<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710595.html
Sent from the POI - User mailing list archive at Nabble.com.

Re: Problem while inserting image multiple times in a worksheet

Posted by Yegor Kozlov <ye...@dinom.ru>.
There is a ongoing effort to impove drawing support in HSSF, we hope
to check min these changes in two or three weeks.
Stay with POI and try a build from trunk after that.

Yegor

On Thu, Aug 2, 2012 at 4:14 PM, harshask <hs...@gmail.com> wrote:
>  I am modifying a template Sir.
>
> On Thu, Aug 2, 2012 at 5:34 PM, Yegor Kozlov-4 [via Apache POI] <
> ml-node+s1045710n5710591h81@n5.nabble.com> wrote:
>
>> Are  you creating a workbook from scratch or modiying a template ?
>>
>>
>> On Thu, Aug 2, 2012 at 3:21 PM, harshask <[hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=0>>
>> wrote:
>>
>> > Hi,
>> >
>> > i used the below code to display image in my excel worksheet.
>> >
>> > try {
>> >             HSSFClientAnchor anchor =
>> >                 new HSSFClientAnchor(0, 0, 255, 255, (short)colNo,
>> rowNo,
>> >                                      (short)++colNo, rowNo);
>> >             int index = wb.addPicture(bytes,
>> > HSSFWorkbook.PICTURE_TYPE_JPEG);
>> >             HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>> >             patriarch.createPicture(anchor, index);
>> >             anchor.setAnchorType(2);
>> >         } catch (Exception e) {
>> >             e.printStackTrace();
>> >         }
>> >
>> > Image is displayed only once, in the place where its executed last.
>> >
>> > I read in a blog that, HSSFPatriarch patriarch =
>> > sheet.createDrawingPatriarch(); removes all the existing shapes in the
>> work
>> > sheet. How can i display the same image many times in a single
>> worksheet?
>> >
>> > Thank you,
>> > Harsha
>> >
>> >
>> >
>> >
>> > --
>> > View this message in context:
>> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588.html
>> > Sent from the POI - User mailing list archive at Nabble.com.
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=1>
>> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=2>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=3>
>> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=4>
>>
>>
>>
>> ------------------------------
>>  If you reply to this email, your message will be added to the discussion
>> below:
>>
>> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710591.html
>>  To unsubscribe from Problem while inserting image multiple times in a
>> worksheet, click here<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5710588&code=aHNrLjE5ODhAZ21haWwuY29tfDU3MTA1ODh8OTA4NTg2NDU=>
>> .
>> NAML<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>>
>
>
>
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710592.html
> Sent from the POI - User mailing list archive at Nabble.com.

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


Re: Problem while inserting image multiple times in a worksheet

Posted by harshask <hs...@gmail.com>.
 I am modifying a template Sir.

On Thu, Aug 2, 2012 at 5:34 PM, Yegor Kozlov-4 [via Apache POI] <
ml-node+s1045710n5710591h81@n5.nabble.com> wrote:

> Are  you creating a workbook from scratch or modiying a template ?
>
>
> On Thu, Aug 2, 2012 at 3:21 PM, harshask <[hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=0>>
> wrote:
>
> > Hi,
> >
> > i used the below code to display image in my excel worksheet.
> >
> > try {
> >             HSSFClientAnchor anchor =
> >                 new HSSFClientAnchor(0, 0, 255, 255, (short)colNo,
> rowNo,
> >                                      (short)++colNo, rowNo);
> >             int index = wb.addPicture(bytes,
> > HSSFWorkbook.PICTURE_TYPE_JPEG);
> >             HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
> >             patriarch.createPicture(anchor, index);
> >             anchor.setAnchorType(2);
> >         } catch (Exception e) {
> >             e.printStackTrace();
> >         }
> >
> > Image is displayed only once, in the place where its executed last.
> >
> > I read in a blog that, HSSFPatriarch patriarch =
> > sheet.createDrawingPatriarch(); removes all the existing shapes in the
> work
> > sheet. How can i display the same image many times in a single
> worksheet?
> >
> > Thank you,
> > Harsha
> >
> >
> >
> >
> > --
> > View this message in context:
> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588.html
> > Sent from the POI - User mailing list archive at Nabble.com.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=1>
> > For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=2>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=3>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5710591&i=4>
>
>
>
> ------------------------------
>  If you reply to this email, your message will be added to the discussion
> below:
>
> http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710591.html
>  To unsubscribe from Problem while inserting image multiple times in a
> worksheet, click here<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5710588&code=aHNrLjE5ODhAZ21haWwuY29tfDU3MTA1ODh8OTA4NTg2NDU=>
> .
> NAML<http://apache-poi.1045710.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>




--
View this message in context: http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588p5710592.html
Sent from the POI - User mailing list archive at Nabble.com.

Re: Problem while inserting image multiple times in a worksheet

Posted by Yegor Kozlov <ye...@dinom.ru>.
Are  you creating a workbook from scratch or modiying a template ?


On Thu, Aug 2, 2012 at 3:21 PM, harshask <hs...@gmail.com> wrote:
> Hi,
>
> i used the below code to display image in my excel worksheet.
>
> try {
>             HSSFClientAnchor anchor =
>                 new HSSFClientAnchor(0, 0, 255, 255, (short)colNo, rowNo,
>                                      (short)++colNo, rowNo);
>             int index = wb.addPicture(bytes,
> HSSFWorkbook.PICTURE_TYPE_JPEG);
>             HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>             patriarch.createPicture(anchor, index);
>             anchor.setAnchorType(2);
>         } catch (Exception e) {
>             e.printStackTrace();
>         }
>
> Image is displayed only once, in the place where its executed last.
>
> I read in a blog that, HSSFPatriarch patriarch =
> sheet.createDrawingPatriarch(); removes all the existing shapes in the work
> sheet. How can i display the same image many times in a single worksheet?
>
> Thank you,
> Harsha
>
>
>
>
> --
> View this message in context: http://apache-poi.1045710.n5.nabble.com/Problem-while-inserting-image-multiple-times-in-a-worksheet-tp5710588.html
> Sent from the POI - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

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