poi-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Schwarze <...@admadic.de>
Subject Re: Creating new word doc with POI
Date Fri, 19 Jan 2007 23:31:33 GMT
At 11:40 19.01.2007, Rainer Klute wrote:
>hasiasat schrieb:
>> Error getting property set with name ♣DocumentSummaryInformation
>> java.io.FileNotFoundException: no such entry:
>> "♣DocumentSummaryInformation"
>> Error getting property set with name ♣SummaryInformation
>> java.io.FileNotFoundException: no such entry: "♣SummaryInformation"
>>   
>
>The property sets DocumentSummaryInformation and SummaryInformation do
>not belong to the Word document as such. You have to create them using
>POI's HPSF component, see <http://jakarta.apache.org/poi/hpsf/> for
>details. I don't know whether HWPF has any functionalities to
>encapsulate the HPSF stuff for you.

HWPFDocument is a subclass of POIDocument. That has readProperties() and
writeProperties(...). readProperties() is called already, but upon a write
the writeProperties is missing. To fix it add a line at the end of the
function HWPFDocument.write(...) as shown below:

  public void write(OutputStream out) throws IOException
  {
    ...
    // spit out the Word document.
    POIFSFileSystem pfs = new POIFSFileSystem();
    pfs.createDocument(new ByteArrayInputStream(mainBuf), "WordDocument");
    pfs.createDocument(new ByteArrayInputStream(tableBuf), "1Table");
    pfs.createDocument(new ByteArrayInputStream(dataBuf), "Data");
    // write the properties:
    writeProperties(pfs);       // <-- insert this
    pfs.writeFilesystem(out);
  }

That should do it.

Best wishes,
Rainer

-- 
Rainer Schwarze  


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


Mime
View raw message