You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by marc <wd...@wilson.dk> on 2005/04/04 12:40:42 UTC

Problem writing xls

I have made a funktion that makes a xls doc from some database tables, 
nothing facy.

Then I made a funktion that reads in the xls, looking for change, adds 
new items and delete items from the database, very basic.

And they both works fin.

BUT the problems comes, if I write the document out to a file, makes no 
chage, dont even open it, move it or nothing.
Then if I tries to run my read funktion on the document. Then it deletes 
the first entry on every sheet, from the database NOT from the xls 
document.But only the first time it runs. If I run it again still with 
no change to the xls document, notning is done to the xls document or 
database. As intended, and the way it should had run the first time.
If I then ad a new entry to the document, it reads in and updates/create 
the new entry and the one's it just delete.

Very annoying, so al help is gladly appreciated :-)


/marc


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Problem writing xls

Posted by marc <wd...@wilson.dk>.
Ok, and thank you worry much.

+marc

Andrew C. Oliver wrote:
> This is a file format port.  The file format does not have the blank
> line.  It is merely the absence of a row.  This is the difference between a
> GRID model/spreadsheet engine and an API that represents the file
> format.  A lot of folks think HSSF is a spreadsheet engine or port of
> Excel or whatever.
> It is a port of the file format only.
> 
> -andy
> 
> marc wrote:
> 
>> Ok that was also me solution.
>>
>> But do anybody now why it is only the first time around it do not take 
>> the blank line?
>>
>> Marc
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Writing properties with HPSF

Posted by Rainer Klute <kl...@rainer-klute.de>.
Am Freitag, den 08.04.2005, 19:09 +0100 schrieb Kais Dukes:
>  I would like to use POI's HPSF project to modify the properties of Office
> documents. I know that I can read properties using HPSF, but my question is,
> does HPSF support writing properties?

Yes, it does. However, the property writing support is not in any
official POI release, but in the CVS repository only.

BTW, it should be possible to replace the "hpsf" subdirectory of the
latest official POI release by the "hpsf" subdirectory from the CVS.
However, I have never tried it.

Best regards
Rainer Klute

                           Rainer Klute IT-Consulting GmbH
  Dipl.-Inform.
  Rainer Klute             E-Mail:  klute@rainer-klute.de
  Körner Grund 24          Telefon: +49 172 2324824
D-44143 Dortmund           Telefax: +49 231 5349423

Inhibit software patents: http://www.nosoftwarepatents.com/


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Writing properties with HPSF

Posted by Kais Dukes <k....@complexar.com>.
 Dear POI Gurus,

 I would like to use POI's HPSF project to modify the properties of Office
documents. I know that I can read properties using HPSF, but my question is,
does HPSF support writing properties?

 Regards,
 -- Kais Dukes


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.859 / Virus Database: 585 - Release Date: 14/02/2005


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Problem writing xls

Posted by "Andrew C. Oliver" <an...@superlinksoftware.com>.
This is a file format port.  The file format does not have the blank
line.  It is merely the absence of a row.  This is the difference between a
GRID model/spreadsheet engine and an API that represents the file
format.  A lot of folks think HSSF is a spreadsheet engine or port of
Excel or whatever.
It is a port of the file format only.

-andy

marc wrote:

> Ok that was also me solution.
>
> But do anybody now why it is only the first time around it do not take 
> the blank line?
>
> Marc
>
>
> Alex Karshakevich wrote:
>
>> The rowIterator iterates only over actual rows. If a row is empty it 
>> may not be represented in the excel file. The iterator skips these 
>> nonexistent rows, so you may not get the same count as the row count 
>> of the sheet.
>> To iterate over _all_rows, null or not, I use HSSFSheet.getRow() and 
>> deal with nulls myself.
>>
>> Alex.
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>




---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Problem writing xls

Posted by marc <wd...@wilson.dk>.
Ok that was also me solution.

But do anybody now why it is only the first time around it do not take 
the blank line?

Marc


Alex Karshakevich wrote:
> The rowIterator iterates only over actual rows. If a row is empty it may 
> not be represented in the excel file. The iterator skips these 
> nonexistent rows, so you may not get the same count as the row count of 
> the sheet.
> To iterate over _all_rows, null or not, I use HSSFSheet.getRow() and 
> deal with nulls myself.
> 
> Alex.
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Problem writing xls

Posted by Alex Karshakevich <al...@thoughtspeed.biz>.
The rowIterator iterates only over actual rows. If a row is empty it may 
not be represented in the excel file. The iterator skips these 
nonexistent rows, so you may not get the same count as the row count of 
the sheet.
To iterate over _all_rows, null or not, I use HSSFSheet.getRow() and 
deal with nulls myself.

Alex.

marc wrote:

>
> Sorry the late reply.
>
> This is the code from where it goes wrong:
>
> I take a sheet and makes a iterator, to go over the rows. Moves the 
> iterator's maker to position 4, because thats where me data starts. 
> Then I check's if the cell in the current row is blank. If it is not. 
> I go thow the rows making them into beans.
> And at last I return the beans in a ArrayList.
>
> But as I said in me first mail. First time I call it on a new sheet it 
> counts 1 short. See the output in the bottom.
>
> private Collection getAlias(HSSFSheet sheet) throws 
> NoRowsExcistException {
>         ConstansForAliasPOI constant = ConstansForAliasPOI.getInstance();
>         ArrayList _alias = new ArrayList();
>         int start = constant.getSTRATOFALIAS();
>         Iterator rows = sheet.rowIterator();
>         HSSFRow curretrow =(HSSFRow) rows.next();
>         for(int n=0;n<start-1;n++)curretrow = (HSSFRow)rows.next();
>
>         MailAliasDTO currentDTO;
>
>         if(!(curretrow.getCell((short)0)==null)){
>             while(rows.hasNext()){
>
>                 curretrow = (HSSFRow) rows.next();
>                 currentDTO = new MailAliasDTO();
>
> currentDTO.setOwner(curretrow.getCell((short)0).getStringCellValue());
>                 currentDTO.setAlias(curretrow.getCell((short 
> )1).getStringCellValue());
>
> currentDTO.setReciver(curretrow.getCell((short)2).getStringCellValue());
>                 _alias.add(currentDTO);
>
>                 }
>         }else{
>             throw new NoRowsExcistException();
>         }
>         System.out.println("My alias list, from my xls, is this long: 
> "+_alias.size()+" when I call getAlias()");
>         return _alias;
>     }
>
>
> Output first run:
> My alias list, from my xls, is this long: 3 when I call getAlias()
>
> But there is 4 lines in me XLS.
> If I then make a change in the XLS or add's one. Lets say I add one, 
> so there is 5 lines in the XLS. And then runs the code, then I get:
> My alias list, from my xls, is this long: 5 when I call getAlias()
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/
>
>


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Problem writing xls

Posted by marc <wd...@wilson.dk>.
Sorry the late reply.

This is the code from where it goes wrong:

I take a sheet and makes a iterator, to go over the rows. Moves the 
iterator's maker to position 4, because thats where me data starts. Then 
I check's if the cell in the current row is blank. If it is not. I go 
thow the rows making them into beans.
And at last I return the beans in a ArrayList.

But as I said in me first mail. First time I call it on a new sheet it 
counts 1 short. See the output in the bottom.

private Collection getAlias(HSSFSheet sheet) throws NoRowsExcistException {
         ConstansForAliasPOI constant = ConstansForAliasPOI.getInstance();
         ArrayList _alias = new ArrayList();
         int start = constant.getSTRATOFALIAS();
         Iterator rows = sheet.rowIterator();
         HSSFRow curretrow =(HSSFRow) rows.next();
         for(int n=0;n<start-1;n++)curretrow = (HSSFRow)rows.next();

         MailAliasDTO currentDTO;

         if(!(curretrow.getCell((short)0)==null)){
             while(rows.hasNext()){

                 curretrow = (HSSFRow) rows.next();
                 currentDTO = new MailAliasDTO(); 

 
currentDTO.setOwner(curretrow.getCell((short)0).getStringCellValue());
                 currentDTO.setAlias(curretrow.getCell((short 
)1).getStringCellValue());
 
currentDTO.setReciver(curretrow.getCell((short)2).getStringCellValue());
                 _alias.add(currentDTO);

                 }
         }else{
             throw new NoRowsExcistException();
         }
         System.out.println("My alias list, from my xls, is this long: 
"+_alias.size()+" when I call getAlias()");
         return _alias;
     }


Output first run:
My alias list, from my xls, is this long: 3 when I call getAlias()

But there is 4 lines in me XLS.
If I then make a change in the XLS or add's one. Lets say I add one, so 
there is 5 lines in the XLS. And then runs the code, then I get:
My alias list, from my xls, is this long: 5 when I call getAlias()


---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/


Re: Problem writing xls

Posted by Danny Mui <da...@muibros.com>.
can we see some sample code, only real way to see if there is a HSSF 
issue or a application coding issue.
marc wrote:

> I have made a funktion that makes a xls doc from some database tables, 
> nothing facy.
>
> Then I made a funktion that reads in the xls, looking for change, adds 
> new items and delete items from the database, very basic.
>
> And they both works fin.
>
> BUT the problems comes, if I write the document out to a file, makes 
> no chage, dont even open it, move it or nothing.
> Then if I tries to run my read funktion on the document. Then it 
> deletes the first entry on every sheet, from the database NOT from the 
> xls document.But only the first time it runs. If I run it again still 
> with no change to the xls document, notning is done to the xls 
> document or database. As intended, and the way it should had run the 
> first time.
> If I then ad a new entry to the document, it reads in and 
> updates/create the new entry and the one's it just delete.
>
> Very annoying, so al help is gladly appreciated :-)
>
>
> /marc
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
> The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/



---------------------------------------------------------------------
To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
Mailing List:     http://jakarta.apache.org/site/mail2.html#poi
The Apache Jakarta Poi Project:  http://jakarta.apache.org/poi/