I tried it, but without result.

I do not get any exception. Closing the streams did not change anything
(actually in the real program I closed them, just forgot it in this
small excert). The issue with the currdir isn't really an issue because
this is just an code snipped that extracts the problem an not the
real program. When this works, it will be replaced by some arguments.

So the question still remains. What is wrong here. In the meantime I
tried to use BIFFViewer. When I run it on the Excel XP template file
I get some undefined records. Does this mean that POI is incompatible
with the new format?


Thanx.


   Martin

"Andrew C. Oliver" wrote:
> 
> Martin Lang wrote:
> > Hi,
> >
> > When I run the following very simple progam and try to open the writen
> > .xls file with Excel XP I get
> > an error message saying that the file is corrupted and some formatting
> > information may got lost.
> > The error occurs only when the file I read in (template.xls) has been
> > created with Excel XP. When
> > I use a file that has been written by Excel 97 everything is o.k.
> >
> > Am I doing something wrong or is this a bug?
> >
> 
> Issues
> 
> 1. Close your output stream.  (and input stream too)
> 2. DO something with the IOException (you may be getting an
> error!)...like e.printStackTrace().
> 3. Secondly, there is no guarantee that its reading "template.xls" from
> the current directory or writing result.xls in the current directory
> (currdir is not defined and is therefore not platform inspecific) ...
> use a real path, suggest making use of args.
> 
> -Andy
> 
> > public static void main(String[] args) {
> >       HSSFWorkbook wb;
> >
> >       try {
> >        FileInputStream template = new FileInputStream("template.xls");
> >        FileOutputStream result = new FileOutputStream(new
> > File("result.xls"));
> >        POIFSFileSystem templatefs = new POIFSFileSystem(template);
> >        wb = new HSSFWorkbook(templatefs);
> >        wb.write(result);
> >       }
> >               catch (IOException e) {
> >       }
> >
> >
> >       }
> >
> >
> >
> >
> > Dr. Martin Lang
> > Cortex Brainware GmbH
> > EMail: [EMAIL PROTECTED]
> 
> --
> To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to