You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br> on 2007/10/11 13:50:45 UTC

Changing .DOC files with HWPF and .PPT files with HSLF

Hi people,

I've been looking for some solution for my problem at POI project's site.
What I need is read a template .PPT file, identify its keys, select each
value (from the database) that fits to each key of the file and generate a
new file, based on the template, with the values selected by the user inside
it.

For the .XLS file format, I found something pretty easy to use at
jxls.sourceforge.net (based on POI) and I wrote this code:

import java.io.IOException;
import java.util.Collection ;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;

import net.sf.jxls.exception.ParsePropertyException;
import net.sf.jxls.transformer.XLSTransformer;


public class TestjXLS {

    public static void main(String args[]){

        Collection<Item> items = new HashSet<Item>();
        items.add(new Item("Luiz", 35, "R. Hermantino Coelho"));

        Map<String,Collection> beans = new HashMap<String,Collection>();
        beans.put("item", items);
        XLSTransformer transformer = new XLSTransformer();

        try {
            transformer.transformXLS("testejXML.xls", beans, "
resultsFromjXML.xls ");
        } catch (ParsePropertyException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

I searched for other projects which could do this, like jXLS for .XLS files
and didn't find too.

Please, does anybody could give me some tip to do this with HWPF and HSLF?

Since now, thanks for any help!

Luiz

Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Rainer Schwarze <rs...@admadic.de>.
Luiz Antonio Falaguasta Barbosa wrote:
> Hi Rainer,
> Now I understood. I have to select Insert > Field, choose IncludePicture
> from Field Names and put a name into Field Name. That is ok.
> I could see that, if I press ALT + F9, I get the following:
> 
>  {INCLUDEPICTURE "prodPic" \d \MERGERFORMAT}
> 
> where, prodPic is the name chosen for field name.
> After that, what should I do?
> Thanks in advance!
> Luiz

Hi Luiz,

in Word files, fields are encoded as sequences of three markers. The
field text which you see in Word, is actually stored as:

<13> INCLUDEPICTURE "prodPic" \d \MERGERFORMAT <14><1><15>

(The numbers in angle brackets are in hex.) Word displays the <13> as
opening brace '{', <15> as closing brace '}'. The <14> is not shown and
the <1> denotes an embedded graphics.

When you insert such a text sequence, you must give it character
properties. The CharacterRun containing <13> (one character) must be
formatted by calling setSpecialCharacter(true). ' INCLUDEPICTURE
"prodPic" \d \MERGERFORMAT ' has no specific formatting and
'<14><1><15>' is again changed by calling setSpecialCharacter(true).
So you should insert the whole field in three steps.

If you need more information, just yell :-)

Best wishes,
Rainer
-- 

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


Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
Hi Rainer,

Now I understood. I have to select Insert > Field, choose IncludePicture
from Field Names and put a name into Field Name. That is ok.

I could see that, if I press ALT + F9, I get the following:

 {INCLUDEPICTURE "prodPic" \d \MERGERFORMAT}

where, prodPic is the name chosen for field name.

After that, what should I do?

Thanks in advance!

Luiz

On 10/11/07, Rainer Schwarze <rs...@admadic.de> wrote:
>
> Luiz Antonio Falaguasta Barbosa wrote:
> > On 10/11/07, Nick Burch <ni...@torchbox.com> wrote:
> >> On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
> >>> And what about the insertion of images, can I change a key by an
> image?
> >> I don't think that's possible, no. Off the top of my head, I can't
> think
> >> of any parts of HWPF that allow adding images, and I don't think the
> HSLF
> >> image code supports that sort of thing yet (but Yegor might prove me
> >> wrong!)
>
> Hi Luiz,
>
> Nick is right regarding adding images in HWPF.
> Insertion of images in HWPF would also require modifying the so called
> data stream in the file which is not taken care of at all now. So it
> would take some heavier changes to support adding images.
>
> If it works for you, you could try to insert fields which only refer to
> external images without storing a copy in the document.
> (INCLUDEPICTURE?) If that's an option, I could offer some advice on
> trying to do it - maybe that works, maybe not.
>
> Best wishes,
> Rainer
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
Hi Rainer,

Thanks for the answer. To yours too, Nick!

Rainer, please, I didn't understand what would you say about inserting
fields. What are these fields in a .DOC file? Could you give me some code
example?

Regards,

Luiz

On 10/11/07, Rainer Schwarze <rs...@admadic.de> wrote:
>
> Luiz Antonio Falaguasta Barbosa wrote:
> > On 10/11/07, Nick Burch <ni...@torchbox.com> wrote:
> >> On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
> >>> And what about the insertion of images, can I change a key by an
> image?
> >> I don't think that's possible, no. Off the top of my head, I can't
> think
> >> of any parts of HWPF that allow adding images, and I don't think the
> HSLF
> >> image code supports that sort of thing yet (but Yegor might prove me
> >> wrong!)
>
> Hi Luiz,
>
> Nick is right regarding adding images in HWPF.
> Insertion of images in HWPF would also require modifying the so called
> data stream in the file which is not taken care of at all now. So it
> would take some heavier changes to support adding images.
>
> If it works for you, you could try to insert fields which only refer to
> external images without storing a copy in the document.
> (INCLUDEPICTURE?) If that's an option, I could offer some advice on
> trying to do it - maybe that works, maybe not.
>
> Best wishes,
> Rainer
> --
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Re[2]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
Thanks Yegor!

On 10/15/07, Yegor Kozlov <ye...@dinom.ru> wrote:
>
>
> http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java
>
> Yegor
>
> > Hi Prachi,
>
> > Could you share the fragment of your code where you put the image into
> the
> > .XLS file?
>
> > I have to do the same with template files. I wanna change keys by images
> in
> > specific cells of the file, but I didn't find how to do it yet.
>
> > For me, doesn't matter if I will loose an original image, because I
> won't
> > have any image into the cell. Actually, I have to create another one
> file
> > with the image (in the new file) instead of the key (that existed in the
> > original file).
>
> > Thanks in advance!
>
> > Luiz
>
> > On 10/12/07, prachi.narkar@contractor.thomson.com <
> > prachi.narkar@contractor.thomson.com> wrote:
> >>
> >> Thanks for your prompt reply!
> >> Yes, the positioning can be achieved, but then as the documentation
> says,
> >> that any existing image would be erased with the new image.
> >>
> >> What I need is that corrsponding to every record (row) in the Excel
> sheet,
> >> I would need an image to be exported.
> >> But with the limitation that it would erase an existing image, wouldnt
> the
> >> existing images exported be erased?
> >> Say I export an image for record 1 and for record 2 the previous image
> >> would be erased and new image added?
> >>
> >> -Prachi
> >>
> >> ________________________________
> >>
> >> From: Nick Burch [mailto:nick@torchbox.com]
> >> Sent: Fri 12/10/2007 11:29
> >> To: POI Users List
> >> Subject: Re: Export an image as PNG to a particular cell in Excel using
> >> POI.
> >>
> >>
> >>
> >> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> >> > I would like to know if we can export an image as PNG to a particular
> >> > cell in Excel using POI.
> >>
> >> I don't think you can actually put an image as the real contents of a
> cell
> >> (it's just not something the excel format supports). I think all you
> can
> >> do is add in an image, then position/size it to occupy the whole cell.
> >>
> >> Nick
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Re[2]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
Hi people,

I ran the example bellow and it is pretty fine!

Is it possible do the same with .DOC and .PPT files?

Thanks in advance!

Luiz

On 10/15/07, Yegor Kozlov <ye...@dinom.ru> wrote:
>
>
> http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java
>
> Yegor
>
> > Hi Prachi,
>
> > Could you share the fragment of your code where you put the image into
> the
> > .XLS file?
>
> > I have to do the same with template files. I wanna change keys by images
> in
> > specific cells of the file, but I didn't find how to do it yet.
>
> > For me, doesn't matter if I will loose an original image, because I
> won't
> > have any image into the cell. Actually, I have to create another one
> file
> > with the image (in the new file) instead of the key (that existed in the
> > original file).
>
> > Thanks in advance!
>
> > Luiz
>
> > On 10/12/07, prachi.narkar@contractor.thomson.com <
> > prachi.narkar@contractor.thomson.com> wrote:
> >>
> >> Thanks for your prompt reply!
> >> Yes, the positioning can be achieved, but then as the documentation
> says,
> >> that any existing image would be erased with the new image.
> >>
> >> What I need is that corrsponding to every record (row) in the Excel
> sheet,
> >> I would need an image to be exported.
> >> But with the limitation that it would erase an existing image, wouldnt
> the
> >> existing images exported be erased?
> >> Say I export an image for record 1 and for record 2 the previous image
> >> would be erased and new image added?
> >>
> >> -Prachi
> >>
> >> ________________________________
> >>
> >> From: Nick Burch [mailto:nick@torchbox.com]
> >> Sent: Fri 12/10/2007 11:29
> >> To: POI Users List
> >> Subject: Re: Export an image as PNG to a particular cell in Excel using
> >> POI.
> >>
> >>
> >>
> >> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> >> > I would like to know if we can export an image as PNG to a particular
> >> > cell in Excel using POI.
> >>
> >> I don't think you can actually put an image as the real contents of a
> cell
> >> (it's just not something the excel format supports). I think all you
> can
> >> do is add in an image, then position/size it to occupy the whole cell.
> >>
> >> Nick
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re[2]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Yegor Kozlov <ye...@dinom.ru>.
http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/hssf/usermodel/examples/OfficeDrawing.java

Yegor

> Hi Prachi,

> Could you share the fragment of your code where you put the image into the
> .XLS file?

> I have to do the same with template files. I wanna change keys by images in
> specific cells of the file, but I didn't find how to do it yet.

> For me, doesn't matter if I will loose an original image, because I won't
> have any image into the cell. Actually, I have to create another one file
> with the image (in the new file) instead of the key (that existed in the
> original file).

> Thanks in advance!

> Luiz

> On 10/12/07, prachi.narkar@contractor.thomson.com <
> prachi.narkar@contractor.thomson.com> wrote:
>>
>> Thanks for your prompt reply!
>> Yes, the positioning can be achieved, but then as the documentation says,
>> that any existing image would be erased with the new image.
>>
>> What I need is that corrsponding to every record (row) in the Excel sheet,
>> I would need an image to be exported.
>> But with the limitation that it would erase an existing image, wouldnt the
>> existing images exported be erased?
>> Say I export an image for record 1 and for record 2 the previous image
>> would be erased and new image added?
>>
>> -Prachi
>>
>> ________________________________
>>
>> From: Nick Burch [mailto:nick@torchbox.com]
>> Sent: Fri 12/10/2007 11:29
>> To: POI Users List
>> Subject: Re: Export an image as PNG to a particular cell in Excel using
>> POI.
>>
>>
>>
>> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
>> > I would like to know if we can export an image as PNG to a particular
>> > cell in Excel using POI.
>>
>> I don't think you can actually put an image as the real contents of a cell
>> (it's just not something the excel format supports). I think all you can
>> do is add in an image, then position/size it to occupy the whole cell.
>>
>> Nick
>>
>> ---------------------------------------------------------------------
>> 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
>>


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


Re: Export an image as PNG to a particular cell in Excel using POI.

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
Understood.

So, to do the same with .DOC and .PPT files is not possible, right?

Is it needed a lot of time to do this in the HPWF and HLSF?

I need something like that, but I think I need some help to put it into POI.

Thanks in advance!

Luiz

On 10/16/07, prachi.narkar@contractor.thomson.com <
prachi.narkar@contractor.thomson.com> wrote:
>
> Hi,
>
> I am attaching a simple servlet that exports image to excel file.
> Please note that you will need POI 3.0.1 version of jar.
> Hope this is useful!
>
> Regards,
> Prachi
>
> ________________________________
>
> From: Luiz Antonio Falaguasta Barbosa [mailto:luiz.barbosa@gwe.com.br]
> Sent: Mon 15/10/2007 12:42
> To: POI Users List
> Subject: Re: Export an image as PNG to a particular cell in Excel using
> POI.
>
>
>
> Hi Prachi,
>
> Could you share the fragment of your code where you put the image into the
> .XLS file?
>
> I have to do the same with template files. I wanna change keys by images
> in
> specific cells of the file, but I didn't find how to do it yet.
>
> For me, doesn't matter if I will loose an original image, because I won't
> have any image into the cell. Actually, I have to create another one file
> with the image (in the new file) instead of the key (that existed in the
> original file).
>
> Thanks in advance!
>
> Luiz
>
> On 10/12/07, prachi.narkar@contractor.thomson.com <
> prachi.narkar@contractor.thomson.com> wrote:
> >
> > Thanks for your prompt reply!
> > Yes, the positioning can be achieved, but then as the documentation
> says,
> > that any existing image would be erased with the new image.
> >
> > What I need is that corrsponding to every record (row) in the Excel
> sheet,
> > I would need an image to be exported.
> > But with the limitation that it would erase an existing image, wouldnt
> the
> > existing images exported be erased?
> > Say I export an image for record 1 and for record 2 the previous image
> > would be erased and new image added?
> >
> > -Prachi
> >
> > ________________________________
> >
> > From: Nick Burch [mailto:nick@torchbox.com]
> > Sent: Fri 12/10/2007 11:29
> > To: POI Users List
> > Subject: Re: Export an image as PNG to a particular cell in Excel using
> > POI.
> >
> >
> >
> > On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> > > I would like to know if we can export an image as PNG to a particular
> > > cell in Excel using POI.
> >
> > I don't think you can actually put an image as the real contents of a
> cell
> > (it's just not something the excel format supports). I think all you can
> > do is add in an image, then position/size it to occupy the whole cell.
> >
> > Nick
> >
> > ---------------------------------------------------------------------
> > 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
> >
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>

RE: Export an image as PNG to a particular cell in Excel using POI.

Posted by pr...@contractor.thomson.com.
Hi,
 
I am attaching a simple servlet that exports image to excel file.
Please note that you will need POI 3.0.1 version of jar.
Hope this is useful!
 
Regards,
Prachi

________________________________

From: Luiz Antonio Falaguasta Barbosa [mailto:luiz.barbosa@gwe.com.br]
Sent: Mon 15/10/2007 12:42
To: POI Users List
Subject: Re: Export an image as PNG to a particular cell in Excel using POI.



Hi Prachi,

Could you share the fragment of your code where you put the image into the
.XLS file?

I have to do the same with template files. I wanna change keys by images in
specific cells of the file, but I didn't find how to do it yet.

For me, doesn't matter if I will loose an original image, because I won't
have any image into the cell. Actually, I have to create another one file
with the image (in the new file) instead of the key (that existed in the
original file).

Thanks in advance!

Luiz

On 10/12/07, prachi.narkar@contractor.thomson.com <
prachi.narkar@contractor.thomson.com> wrote:
>
> Thanks for your prompt reply!
> Yes, the positioning can be achieved, but then as the documentation says,
> that any existing image would be erased with the new image.
>
> What I need is that corrsponding to every record (row) in the Excel sheet,
> I would need an image to be exported.
> But with the limitation that it would erase an existing image, wouldnt the
> existing images exported be erased?
> Say I export an image for record 1 and for record 2 the previous image
> would be erased and new image added?
>
> -Prachi
>
> ________________________________
>
> From: Nick Burch [mailto:nick@torchbox.com]
> Sent: Fri 12/10/2007 11:29
> To: POI Users List
> Subject: Re: Export an image as PNG to a particular cell in Excel using
> POI.
>
>
>
> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> > I would like to know if we can export an image as PNG to a particular
> > cell in Excel using POI.
>
> I don't think you can actually put an image as the real contents of a cell
> (it's just not something the excel format supports). I think all you can
> do is add in an image, then position/size it to occupy the whole cell.
>
> Nick
>
> ---------------------------------------------------------------------
> 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
>




Re: Export an image as PNG to a particular cell in Excel using POI.

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
Hi Prachi,

Could you share the fragment of your code where you put the image into the
.XLS file?

I have to do the same with template files. I wanna change keys by images in
specific cells of the file, but I didn't find how to do it yet.

For me, doesn't matter if I will loose an original image, because I won't
have any image into the cell. Actually, I have to create another one file
with the image (in the new file) instead of the key (that existed in the
original file).

Thanks in advance!

Luiz

On 10/12/07, prachi.narkar@contractor.thomson.com <
prachi.narkar@contractor.thomson.com> wrote:
>
> Thanks for your prompt reply!
> Yes, the positioning can be achieved, but then as the documentation says,
> that any existing image would be erased with the new image.
>
> What I need is that corrsponding to every record (row) in the Excel sheet,
> I would need an image to be exported.
> But with the limitation that it would erase an existing image, wouldnt the
> existing images exported be erased?
> Say I export an image for record 1 and for record 2 the previous image
> would be erased and new image added?
>
> -Prachi
>
> ________________________________
>
> From: Nick Burch [mailto:nick@torchbox.com]
> Sent: Fri 12/10/2007 11:29
> To: POI Users List
> Subject: Re: Export an image as PNG to a particular cell in Excel using
> POI.
>
>
>
> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> > I would like to know if we can export an image as PNG to a particular
> > cell in Excel using POI.
>
> I don't think you can actually put an image as the real contents of a cell
> (it's just not something the excel format supports). I think all you can
> do is add in an image, then position/size it to occupy the whole cell.
>
> Nick
>
> ---------------------------------------------------------------------
> 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
>

Re: Re[4]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Christophe Charles <ch...@gmail.com>.
Thank Yegor !

I've change my eclipse.ini file like :
-vmargs
-Xms512m
-Xmx768m

And I put this values in the Eclipse'menu :
Window/Preferences/Tomcat/Parameters JVM/

Now it seems work fine !

Regards

Chris

2007/10/18, Yegor Kozlov <ye...@dinom.ru>:
>
> OutOfMemory when creating large excel files is a limitation of POI.
> The only way to solve the OutOfMemory problem is to provide larger
> heap value.
> We have plans to improve it. Hope to get it fixed in future versions
> of POI.
>
> Yegor
>
> > Hi Yehor,
>
> > I have to build a workbook with one sheet and 16500rows x 30cells, but
> it's
> > don't !
>
> > This is a servlet' Tomcat and around 10000rows the process stop (out of
> > memory).
>
> > I'm use :
> > Eclipse 3.2
> > Tomcat 5.0.18
> > Win XP Pro 2002 SP2
> > 3 Ghz 1Go
>
> > My JVM configuration :
> > -vmargs
> > -Xms512m
> > -Xmx512m
> > -XX:PermSize=512m
> > -XX:MaxPermSize=512m
>
>
>
> > The code :
>
> > public void addAResulset(ArrayList aResulset, int startLine) {
> >     for (int line = 0; line < aResulset.size(); line++) {
> >       addRow((ArrayList)aResulset.get(line), startLine + line, null);
> >     }
> > }
>
> > public void addRow(ArrayList rowData, int numLigne, HSSFCellStyle
> cellStyle)
> > {
> >     SimpleDateFormat formatDateFR = new SimpleDateFormat("dd/MM/yyyy");
> >     Timestamp typeDate = new Timestamp(0);
> >     BigDecimal typeNumber = new BigDecimal(0);
>
> >     HSSFRow row = null;
> >     HSSFCell cell = null;
>
> >     row = this._sheet.createRow(numLigne);
>
> >     for (int i = 0; i < rowData.size (); i++) {
> >       cell = row.createCell((short) i);
>
> >       if (cellStyle != null) {
> >         cell.setCellStyle(cellStyle);
> >       }
>
> >       Object object = (Object)rowData.get(i);
>
> >       if (object != null) {
> >         if (object.getClass().isInstance(typeDate)) {
> >           Date date = (Date)object;
> >           cell.setCellValue(new HSSFRichTextString(formatDateFR.format
> > (date)));
> >         } else if (object.getClass().isInstance(typeNumber)) {
> >           Number number = (Number)object;
> >           cell.setCellValue(number.doubleValue());
> >         } else {
> >           cell.setCellValue(new
> > HSSFRichTextString(((String)object).trim()));
> >         }
> >       } else {
> >         cell.setCellValue(new HSSFRichTextString(""));
> >       }
> >     }
> >   }
>
>
> > Any idea or information ?
> > Thanks
>
> > Regards
>
> > Chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re[4]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Yegor Kozlov <ye...@dinom.ru>.
OutOfMemory when creating large excel files is a limitation of POI.
The only way to solve the OutOfMemory problem is to provide larger
heap value.
We have plans to improve it. Hope to get it fixed in future versions
of POI.

Yegor

> Hi Yehor,

> I have to build a workbook with one sheet and 16500rows x 30cells, but it's
> don't !

> This is a servlet' Tomcat and around 10000rows the process stop (out of
> memory).

> I'm use :
> Eclipse 3.2
> Tomcat 5.0.18
> Win XP Pro 2002 SP2
> 3 Ghz 1Go

> My JVM configuration :
> -vmargs
> -Xms512m
> -Xmx512m
> -XX:PermSize=512m
> -XX:MaxPermSize=512m



> The code :

> public void addAResulset(ArrayList aResulset, int startLine) {
>     for (int line = 0; line < aResulset.size(); line++) {
>       addRow((ArrayList)aResulset.get(line), startLine + line, null);
>     }
> }

> public void addRow(ArrayList rowData, int numLigne, HSSFCellStyle cellStyle)
> {
>     SimpleDateFormat formatDateFR = new SimpleDateFormat("dd/MM/yyyy");
>     Timestamp typeDate = new Timestamp(0);
>     BigDecimal typeNumber = new BigDecimal(0);

>     HSSFRow row = null;
>     HSSFCell cell = null;

>     row = this._sheet.createRow(numLigne);

>     for (int i = 0; i < rowData.size(); i++) {
>       cell = row.createCell((short) i);

>       if (cellStyle != null) {
>         cell.setCellStyle(cellStyle);
>       }

>       Object object = (Object)rowData.get(i);

>       if (object != null) {
>         if (object.getClass().isInstance(typeDate)) {
>           Date date = (Date)object;
>           cell.setCellValue(new HSSFRichTextString(formatDateFR.format
> (date)));
>         } else if (object.getClass().isInstance(typeNumber)) {
>           Number number = (Number)object;
>           cell.setCellValue(number.doubleValue());
>         } else {
>           cell.setCellValue(new
> HSSFRichTextString(((String)object).trim()));
>         }
>       } else {
>         cell.setCellValue(new HSSFRichTextString(""));
>       }
>     }
>   }


> Any idea or information ?
> Thanks

> Regards

> Chris


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


Re: Re[2]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Christophe Charles <ch...@gmail.com>.
Hi Yehor,

I have to build a workbook with one sheet and 16500rows x 30cells, but it's
don't !

This is a servlet' Tomcat and around 10000rows the process stop (out of
memory).

I'm use :
Eclipse 3.2
Tomcat 5.0.18
Win XP Pro 2002 SP2
3 Ghz 1Go

My JVM configuration :
-vmargs
-Xms512m
-Xmx512m
-XX:PermSize=512m
-XX:MaxPermSize=512m



The code :

public void addAResulset(ArrayList aResulset, int startLine) {
    for (int line = 0; line < aResulset.size(); line++) {
      addRow((ArrayList)aResulset.get(line), startLine + line, null);
    }
}

public void addRow(ArrayList rowData, int numLigne, HSSFCellStyle cellStyle)
{
    SimpleDateFormat formatDateFR = new SimpleDateFormat("dd/MM/yyyy");
    Timestamp typeDate = new Timestamp(0);
    BigDecimal typeNumber = new BigDecimal(0);

    HSSFRow row = null;
    HSSFCell cell = null;

    row = this._sheet.createRow(numLigne);

    for (int i = 0; i < rowData.size(); i++) {
      cell = row.createCell((short) i);

      if (cellStyle != null) {
        cell.setCellStyle(cellStyle);
      }

      Object object = (Object)rowData.get(i);

      if (object != null) {
        if (object.getClass().isInstance(typeDate)) {
          Date date = (Date)object;
          cell.setCellValue(new HSSFRichTextString(formatDateFR.format
(date)));
        } else if (object.getClass().isInstance(typeNumber)) {
          Number number = (Number)object;
          cell.setCellValue(number.doubleValue());
        } else {
          cell.setCellValue(new
HSSFRichTextString(((String)object).trim()));
        }
      } else {
        cell.setCellValue(new HSSFRichTextString(""));
      }
    }
  }


Any idea or information ?
Thanks

Regards

Chris

Re[6]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Yegor Kozlov <ye...@dinom.ru>.
Prachi, you have to options:

 (a) download the latest build and try HSSFPicture.resize(). It will
 resize the image to its original dimensions.
 (b) Specify the image position when constructing HSSFClientAnchor. In
 this case you set the upper-left and bottom-right coordinates.
 From your previous post I understood you wanted to fit the image in 1
 column and 1 row. If so, the anchor should be
 new HSSFClientAnchor(0,0,0,0,(short)2,i,(short)5,i+1).
 
 anchor.setAnchorType() does not affect the image position. To better
 understand it, insert an image with anchor.setAnchorType(1) and open the
 workbook in Excel. Go to the Format Picture dialog, Properties tab.
 Here is your setting. Try to resize columns. Try to change this
 property and see how Excel behaves when you resize columns.

Regards,
Yegor

> Hi,
>  
> I will try getting the latest build and try this method.
> thanks!
>  
> The sample code I am currently using is:
>  
> try{
>         HSSFWorkbook wb = new HSSFWorkbook();
>         HSSFSheet sheet = wb.createSheet("new sheet"); 
>              
>         sheet.setColumnWidth((short)2, (short) 5250);

>             HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
>             HSSFClientAnchor anchor; 
>             
>              for(int i=0;i<2;i++){  
>                                 
>                 HSSFRow row     = sheet.createRow((short)i);
>                 HSSFCell cell   = row.createCell((short)0);
>         
>                 row.createCell((short)0).setCellValue(i+1);
>                 row.createCell((short)1).setCellValue("Compound " + (i+1));
>                 row.setHeight((short)2500);       
>                 //sheet.addMergedRegion(new
> Region(i,(short)2,i,(short)5));        
>                 
>                 anchor = new
> HSSFClientAnchor(0,0,0,0,(short)2,i,(short)5,i);
>                 anchor.setAnchorType( 3 ); --tried using 2 as well!
>                 patriarch.createPicture(anchor, loadPicture( <image path>, wb ));
>              }
>              
>         }catch(IOException ex)
>         {
>             System.out.println("Error!!");
>         }
>  
> This resizes the image and extends as per the row height and column width.
>  
> Let me know if theres something I am missing or doing incorrectly.
>  
> Regards,
> PRachi

> ________________________________

> From: Yegor Kozlov [mailto:yegor@dinom.ru]
> Sent: Fri 19/10/2007 13:58
> To: POI Users List
> Subject: Re[4]: Export an image as PNG to a particular cell in Excel using POI.




>>
>> I could not find HSSFPicture.resize() .
>> May be I dont have the updated APIs.
> You need to build POI from svn or download a daily build from
> http://encore.torchbox.com/poi-svn-build/.

>> But would this retain the original size of the image?
> Yes, HSSFPicture.resize() adjusts anchor to the actual image
> dimensions.

>> 
>> Even if I set the anchor type to 2 or 3, it does resize the image
>> and extends to the number of columns specified.
>> Am I missing something?
>>

> Would you provide sample code?

> Yegor

>> ________________________________

>> From: Yegor Kozlov [mailto:yegor@dinom.ru]
>> Sent: Tue 16/10/2007 15:04
>> To: POI Users List
>> Subject: Re[2]: Export an image as PNG to a particular cell in Excel using POI.



>> I've recently added HSSFPicture.resize() which resizes image anchor to
>> the actual width and height.  It might be useful to you.

>> If you want to set the anchor manually you need to change the anchor
>> type as follows:
>>  anchor.setAnchorType(2); //Move but don't size with cells

>> By default anchor type=0 which means "Move and size with Cells" and it
>> is what is happening with your image: it gets resized when you resize
>> the columns.

>>> Also, if I need to fit the image to just 1 column and 1row and not
>>> span multiple cols/rows, how should the following API be used:
>>> anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
>>> I am quite confused on the x/y coordinates.

>> The first four values define the offset in the top-left and
>> bottom-right cells. If you need to fit an image to exactly 1 column
>> and 1 row leave them 0. The next four values are 0-based coordinates of
>> the top-left and bottom-right cells.

>> So, to put an image in 1x1 cell the anchor would be

>> new HSSFClientAnchor(0,0,0,0,(short)col1, row1,(short)(col1+1), row+1);

>> where col1 and row1 are coordinates of the top-left cell.

>> Regards,
>> Yegor

>>> Any help on its usage would be appreciated.
>>>
>>> Thanks,
>>> Prachi

>>> ________________________________

>>> From: Nick Burch [mailto:nick@torchbox.com]
>>> Sent: Mon 15/10/2007 11:19
>>> To: POI Users List
>>> Subject: RE: Export an image as PNG to a particular cell in Excel using POI.



>>> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
>>>> Yes, the positioning can be achieved, but then as the documentation
>>>> says, that any existing image would be erased with the new image.

>>> I didn't write the code so I can't be sure, but I have a feeling that the
>>> warning relates to images already in the file when you start, not ones you
>>> add in. So, you ought to be fine to open the file up, and add several
>>> images to it before closing.

>>> Nick

>>> ---------------------------------------------------------------------
>>> 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






> ---------------------------------------------------------------------
> 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


RE: Re[4]: Export an image as PNG to a particular cell in Excel using POI.

Posted by pr...@contractor.thomson.com.
Hi,
 
I will try getting the latest build and try this method.
thanks!
 
The sample code I am currently using is:
 
try{
        HSSFWorkbook wb = new HSSFWorkbook();
        HSSFSheet sheet = wb.createSheet("new sheet"); 
             
        sheet.setColumnWidth((short)2, (short) 5250);

            HSSFPatriarch patriarch = sheet.createDrawingPatriarch();
            HSSFClientAnchor anchor; 
            
             for(int i=0;i<2;i++){  
                                
                HSSFRow row     = sheet.createRow((short)i);
                HSSFCell cell   = row.createCell((short)0);
        
                row.createCell((short)0).setCellValue(i+1);
                row.createCell((short)1).setCellValue("Compound " + (i+1));
                row.setHeight((short)2500);       
                //sheet.addMergedRegion(new Region(i,(short)2,i,(short)5));        
                
                anchor = new HSSFClientAnchor(0,0,0,0,(short)2,i,(short)5,i);
                anchor.setAnchorType( 3 ); --tried using 2 as well!
                patriarch.createPicture(anchor, loadPicture( <image path>, wb ));
             }
             
        }catch(IOException ex)
        {
            System.out.println("Error!!");
        }
 
This resizes the image and extends as per the row height and column width.
 
Let me know if theres something I am missing or doing incorrectly.
 
Regards,
PRachi

________________________________

From: Yegor Kozlov [mailto:yegor@dinom.ru]
Sent: Fri 19/10/2007 13:58
To: POI Users List
Subject: Re[4]: Export an image as PNG to a particular cell in Excel using POI.




>
> I could not find HSSFPicture.resize() .
> May be I dont have the updated APIs.
You need to build POI from svn or download a daily build from http://encore.torchbox.com/poi-svn-build/.

> But would this retain the original size of the image?
Yes, HSSFPicture.resize() adjusts anchor to the actual image
dimensions.

> 
> Even if I set the anchor type to 2 or 3, it does resize the image
> and extends to the number of columns specified.
> Am I missing something?
>

Would you provide sample code?

Yegor

> ________________________________

> From: Yegor Kozlov [mailto:yegor@dinom.ru]
> Sent: Tue 16/10/2007 15:04
> To: POI Users List
> Subject: Re[2]: Export an image as PNG to a particular cell in Excel using POI.



> I've recently added HSSFPicture.resize() which resizes image anchor to
> the actual width and height.  It might be useful to you.

> If you want to set the anchor manually you need to change the anchor
> type as follows:
>  anchor.setAnchorType(2); //Move but don't size with cells

> By default anchor type=0 which means "Move and size with Cells" and it
> is what is happening with your image: it gets resized when you resize
> the columns.

>> Also, if I need to fit the image to just 1 column and 1row and not
>> span multiple cols/rows, how should the following API be used:
>> anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
>> I am quite confused on the x/y coordinates.

> The first four values define the offset in the top-left and
> bottom-right cells. If you need to fit an image to exactly 1 column
> and 1 row leave them 0. The next four values are 0-based coordinates of
> the top-left and bottom-right cells.

> So, to put an image in 1x1 cell the anchor would be

> new HSSFClientAnchor(0,0,0,0,(short)col1, row1,(short)(col1+1), row+1);

> where col1 and row1 are coordinates of the top-left cell.

> Regards,
> Yegor

>> Any help on its usage would be appreciated.
>>
>> Thanks,
>> Prachi

>> ________________________________

>> From: Nick Burch [mailto:nick@torchbox.com]
>> Sent: Mon 15/10/2007 11:19
>> To: POI Users List
>> Subject: RE: Export an image as PNG to a particular cell in Excel using POI.



>> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
>>> Yes, the positioning can be achieved, but then as the documentation
>>> says, that any existing image would be erased with the new image.

>> I didn't write the code so I can't be sure, but I have a feeling that the
>> warning relates to images already in the file when you start, not ones you
>> add in. So, you ought to be fine to open the file up, and add several
>> images to it before closing.

>> Nick

>> ---------------------------------------------------------------------
>> 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






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





Re[4]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Yegor Kozlov <ye...@dinom.ru>.
>
> I could not find HSSFPicture.resize() .
> May be I dont have the updated APIs.
You need to build POI from svn or download a daily build from http://encore.torchbox.com/poi-svn-build/.

> But would this retain the original size of the image?
Yes, HSSFPicture.resize() adjusts anchor to the actual image
dimensions.

>  
> Even if I set the anchor type to 2 or 3, it does resize the image
> and extends to the number of columns specified.
> Am I missing something?
>

Would you provide sample code?

Yegor

> ________________________________

> From: Yegor Kozlov [mailto:yegor@dinom.ru]
> Sent: Tue 16/10/2007 15:04
> To: POI Users List
> Subject: Re[2]: Export an image as PNG to a particular cell in Excel using POI.



> I've recently added HSSFPicture.resize() which resizes image anchor to
> the actual width and height.  It might be useful to you.

> If you want to set the anchor manually you need to change the anchor
> type as follows:
>  anchor.setAnchorType(2); //Move but don't size with cells

> By default anchor type=0 which means "Move and size with Cells" and it
> is what is happening with your image: it gets resized when you resize
> the columns.

>> Also, if I need to fit the image to just 1 column and 1row and not
>> span multiple cols/rows, how should the following API be used:
>> anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
>> I am quite confused on the x/y coordinates.

> The first four values define the offset in the top-left and
> bottom-right cells. If you need to fit an image to exactly 1 column
> and 1 row leave them 0. The next four values are 0-based coordinates of
> the top-left and bottom-right cells.

> So, to put an image in 1x1 cell the anchor would be

> new HSSFClientAnchor(0,0,0,0,(short)col1, row1,(short)(col1+1), row+1);

> where col1 and row1 are coordinates of the top-left cell.

> Regards,
> Yegor

>> Any help on its usage would be appreciated.
>> 
>> Thanks,
>> Prachi

>> ________________________________

>> From: Nick Burch [mailto:nick@torchbox.com]
>> Sent: Mon 15/10/2007 11:19
>> To: POI Users List
>> Subject: RE: Export an image as PNG to a particular cell in Excel using POI.



>> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
>>> Yes, the positioning can be achieved, but then as the documentation
>>> says, that any existing image would be erased with the new image.

>> I didn't write the code so I can't be sure, but I have a feeling that the
>> warning relates to images already in the file when you start, not ones you
>> add in. So, you ought to be fine to open the file up, and add several
>> images to it before closing.

>> Nick

>> ---------------------------------------------------------------------
>> 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






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


RE: Re[2]: Export an image as PNG to a particular cell in Excel using POI.

Posted by pr...@contractor.thomson.com.
Hi,
 
I could not find HSSFPicture.resize() .
May be I dont have the updated APIs.
But would this retain the original size of the image?
 
Even if I set the anchor type to 2 or 3, it does resize the image and extends to the number of columns specified.
Am I missing something?
 
-Prachi

________________________________

From: Yegor Kozlov [mailto:yegor@dinom.ru]
Sent: Tue 16/10/2007 15:04
To: POI Users List
Subject: Re[2]: Export an image as PNG to a particular cell in Excel using POI.



I've recently added HSSFPicture.resize() which resizes image anchor to
the actual width and height.  It might be useful to you.

If you want to set the anchor manually you need to change the anchor
type as follows:
 anchor.setAnchorType(2); //Move but don't size with cells

By default anchor type=0 which means "Move and size with Cells" and it
is what is happening with your image: it gets resized when you resize
the columns.

> Also, if I need to fit the image to just 1 column and 1row and not
> span multiple cols/rows, how should the following API be used:
> anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
> I am quite confused on the x/y coordinates.

The first four values define the offset in the top-left and
bottom-right cells. If you need to fit an image to exactly 1 column
and 1 row leave them 0. The next four values are 0-based coordinates of
the top-left and bottom-right cells.

So, to put an image in 1x1 cell the anchor would be

new HSSFClientAnchor(0,0,0,0,(short)col1, row1,(short)(col1+1), row+1);

where col1 and row1 are coordinates of the top-left cell.

Regards,
Yegor

> Any help on its usage would be appreciated.
> 
> Thanks,
> Prachi

> ________________________________

> From: Nick Burch [mailto:nick@torchbox.com]
> Sent: Mon 15/10/2007 11:19
> To: POI Users List
> Subject: RE: Export an image as PNG to a particular cell in Excel using POI.



> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
>> Yes, the positioning can be achieved, but then as the documentation
>> says, that any existing image would be erased with the new image.

> I didn't write the code so I can't be sure, but I have a feeling that the
> warning relates to images already in the file when you start, not ones you
> add in. So, you ought to be fine to open the file up, and add several
> images to it before closing.

> Nick

> ---------------------------------------------------------------------
> 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





Re[2]: Export an image as PNG to a particular cell in Excel using POI.

Posted by Yegor Kozlov <ye...@dinom.ru>.
I've recently added HSSFPicture.resize() which resizes image anchor to
the actual width and height.  It might be useful to you.

If you want to set the anchor manually you need to change the anchor
type as follows:
 anchor.setAnchorType(2); //Move but don't size with cells

By default anchor type=0 which means "Move and size with Cells" and it
is what is happening with your image: it gets resized when you resize
the columns.

> Also, if I need to fit the image to just 1 column and 1row and not
> span multiple cols/rows, how should the following API be used:
> anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
> I am quite confused on the x/y coordinates.

The first four values define the offset in the top-left and
bottom-right cells. If you need to fit an image to exactly 1 column
and 1 row leave them 0. The next four values are 0-based coordinates of
the top-left and bottom-right cells.

So, to put an image in 1x1 cell the anchor would be

new HSSFClientAnchor(0,0,0,0,(short)col1, row1,(short)(col1+1), row+1);

where col1 and row1 are coordinates of the top-left cell.

Regards,
Yegor

> Any help on its usage would be appreciated.
>  
> Thanks,
> Prachi

> ________________________________

> From: Nick Burch [mailto:nick@torchbox.com]
> Sent: Mon 15/10/2007 11:19
> To: POI Users List
> Subject: RE: Export an image as PNG to a particular cell in Excel using POI.



> On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
>> Yes, the positioning can be achieved, but then as the documentation
>> says, that any existing image would be erased with the new image.

> I didn't write the code so I can't be sure, but I have a feeling that the
> warning relates to images already in the file when you start, not ones you
> add in. So, you ought to be fine to open the file up, and add several
> images to it before closing.

> Nick

> ---------------------------------------------------------------------
> 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


RE: Export an image as PNG to a particular cell in Excel using POI.

Posted by pr...@contractor.thomson.com.
Thanks!
I tried exporting multiple images, with different row/col position and it exports them fine.
 
But I tried to fit the image to single column and row - i.e. resize row and column to fit the image, but somehow the row does not resize.
Also, the image stretches as much as I increase the column width.
I have used the following code:
        sheet.setColumnWidth((short)2, (short)7500);
        sheet.setDefaultRowHeight((short) 3000);
 
Also, if I need to fit the image to just 1 column and 1row and not span multiple cols/rows, how should the following API be used:
anchor = new HSSFClientAnchor(0,0,0,255,(short)2,2,(short)4,7);
I am quite confused on the x/y coordinates.
Any help on its usage would be appreciated.
 
Thanks,
Prachi

________________________________

From: Nick Burch [mailto:nick@torchbox.com]
Sent: Mon 15/10/2007 11:19
To: POI Users List
Subject: RE: Export an image as PNG to a particular cell in Excel using POI.



On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> Yes, the positioning can be achieved, but then as the documentation
> says, that any existing image would be erased with the new image.

I didn't write the code so I can't be sure, but I have a feeling that the
warning relates to images already in the file when you start, not ones you
add in. So, you ought to be fine to open the file up, and add several
images to it before closing.

Nick

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





RE: Export an image as PNG to a particular cell in Excel using POI.

Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> Yes, the positioning can be achieved, but then as the documentation 
> says, that any existing image would be erased with the new image.

I didn't write the code so I can't be sure, but I have a feeling that the 
warning relates to images already in the file when you start, not ones you 
add in. So, you ought to be fine to open the file up, and add several 
images to it before closing.

Nick

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


RE: Export an image as PNG to a particular cell in Excel using POI.

Posted by pr...@contractor.thomson.com.
Thanks for your prompt reply!
Yes, the positioning can be achieved, but then as the documentation says, that any existing image would be erased with the new image.
 
What I need is that corrsponding to every record (row) in the Excel sheet, I would need an image to be exported.
But with the limitation that it would erase an existing image, wouldnt the existing images exported be erased?
Say I export an image for record 1 and for record 2 the previous image would be erased and new image added?
 
-Prachi

________________________________

From: Nick Burch [mailto:nick@torchbox.com]
Sent: Fri 12/10/2007 11:29
To: POI Users List
Subject: Re: Export an image as PNG to a particular cell in Excel using POI.



On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> I would like to know if we can export an image as PNG to a particular
> cell in Excel using POI.

I don't think you can actually put an image as the real contents of a cell
(it's just not something the excel format supports). I think all you can
do is add in an image, then position/size it to occupy the whole cell.

Nick

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





Re: Export an image as PNG to a particular cell in Excel using POI.

Posted by Nick Burch <ni...@torchbox.com>.
On Fri, 12 Oct 2007, prachi.narkar@contractor.thomson.com wrote:
> I would like to know if we can export an image as PNG to a particular 
> cell in Excel using POI.

I don't think you can actually put an image as the real contents of a cell 
(it's just not something the excel format supports). I think all you can 
do is add in an image, then position/size it to occupy the whole cell.

Nick

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


Export an image as PNG to a particular cell in Excel using POI.

Posted by pr...@contractor.thomson.com.
Hi,
 
I would like to know if we can export an image as PNG to a particular cell in Excel using POI.
 
I have refered to the examples given on the website and tried exporting an image to excel.
It works fine for image to excel worksheet, but there are no APIs that would enable image export to a cell.
cell.SetCellValue() does not list any way to have image or even btye array/stream to be written to the cell.
 
Is this, what I am expecting to do, not possible using POI API?
 
Regards,
Prachi


Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Rainer Schwarze <rs...@admadic.de>.
Luiz Antonio Falaguasta Barbosa wrote:
> On 10/11/07, Nick Burch <ni...@torchbox.com> wrote:
>> On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
>>> And what about the insertion of images, can I change a key by an image?
>> I don't think that's possible, no. Off the top of my head, I can't think
>> of any parts of HWPF that allow adding images, and I don't think the HSLF
>> image code supports that sort of thing yet (but Yegor might prove me
>> wrong!)

Hi Luiz,

Nick is right regarding adding images in HWPF.
Insertion of images in HWPF would also require modifying the so called
data stream in the file which is not taken care of at all now. So it
would take some heavier changes to support adding images.

If it works for you, you could try to insert fields which only refer to
external images without storing a copy in the document.
(INCLUDEPICTURE?) If that's an option, I could offer some advice on
trying to do it - maybe that works, maybe not.

Best wishes,
Rainer
-- 

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


Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
> Could you or anybody give me some example of with character run and 
> RichTextRun, or could I find it in the examples from SVN?

http://poi.apache.org/hslf/quick-guide.html
http://poi.apache.org/hwpf/quick-guide.html

Plus you ought to find some of the unit tests (especially for hslf) 
that'll show you how it's done

Nick

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


Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
On 10/11/07, Nick Burch <ni...@torchbox.com> wrote:
>
> On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
> > And what about the text formatting of files generated? Could I choose
> > the format of values before generate the files?
>
> That ought to be fine. As long as you step down to the lowest level of
> text (character run in word, RichTextRun in powerpoint) and change the
> text there, then your new text ought to get the same formatting as the old
> token had.


Could you or anybody give me some example of with character run and
RichTextRun, or could I find it in the examples from SVN?

(Slight caveat - the formatting stuff in hwpf can sometimes get confused
> when changing text, so you might hit issues. Alas we're in need of a new
> hwpf champion to fix this sort of thing)
>
> > And what about the insertion of images, can I change a key by an image?
>
> I don't think that's possible, no. Off the top of my head, I can't think
> of any parts of HWPF that allow adding images, and I don't think the HSLF
> image code supports that sort of thing yet (but Yegor might prove me
> wrong!)


Understood. I think I neither see that the swap of stuff (elements) is
possible with HSLF. I think I saw only something about putting stuff before
or after another thing.

Luiz

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

Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
> And what about the text formatting of files generated? Could I choose 
> the format of values before generate the files?

That ought to be fine. As long as you step down to the lowest level of 
text (character run in word, RichTextRun in powerpoint) and change the 
text there, then your new text ought to get the same formatting as the old 
token had.

(Slight caveat - the formatting stuff in hwpf can sometimes get confused 
when changing text, so you might hit issues. Alas we're in need of a new 
hwpf champion to fix this sort of thing)

> And what about the insertion of images, can I change a key by an image?

I don't think that's possible, no. Off the top of my head, I can't think 
of any parts of HWPF that allow adding images, and I don't think the HSLF 
image code supports that sort of thing yet (but Yegor might prove me 
wrong!)

Nick

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


Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Luiz Antonio Falaguasta Barbosa <lu...@gwe.com.br>.
Fine Nick!

And what about the text formatting of files generated? Could I choose the
format of values before generate the files?

And what about the insertion of images, can I change a key by an image?

Thanks!

Luiz

On 10/11/07, Nick Burch <ni...@torchbox.com> wrote:
>
> On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
> > What I need is read a template .PPT file, identify its keys, select each
> > value (from the database) that fits to each key of the file and generate
> > a new file, based on the template, with the values selected by the user
> > inside it.
>
> You'll need to open up your template file, then loop over all the sheets,
> looking at their textual content. In there, spot your template keys, and
> look them up. Replace the text with the version containing the values, and
> write back out.
>
> The proceedure for hwpf for word docs is fairly similar, but IIRC you'll
> need to go all the way down to the character runs to alter the text, so it
> won't break the formatting
>
> Nick
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
> For additional commands, e-mail: user-help@poi.apache.org
>
>

Re: Changing .DOC files with HWPF and .PPT files with HSLF

Posted by Nick Burch <ni...@torchbox.com>.
On Thu, 11 Oct 2007, Luiz Antonio Falaguasta Barbosa wrote:
> What I need is read a template .PPT file, identify its keys, select each 
> value (from the database) that fits to each key of the file and generate 
> a new file, based on the template, with the values selected by the user 
> inside it.

You'll need to open up your template file, then loop over all the sheets, 
looking at their textual content. In there, spot your template keys, and 
look them up. Replace the text with the version containing the values, and 
write back out.

The proceedure for hwpf for word docs is fairly similar, but IIRC you'll 
need to go all the way down to the character runs to alter the text, so it 
won't break the formatting

Nick

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