You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Meike Reichle <mr...@rz.uni-hildesheim.de> on 2003/06/25 22:02:25 UTC

diagrams

Hi all,

I looked through the mailing list and saw that there are still some problems with excel files that contain diagrams. 
I have pretty much the same problem than some other people before me I think. I want to read in a template containing a diagram, add some data and save it again. But whenever I try to open this file using POI I get a nullpointer exception.
This is the method I use:

public static HSSFWorkbook openFile(String filename)
 {
  try
  {
   // read the specified file in 
   FileInputStream in = new FileInputStream(filename);
   // direct this input stream is a POI file system
   POIFSFileSystem fs = new POIFSFileSystem(in);
   // open the Excel file in this file system
   HSSFWorkbook wb = new HSSFWorkbook(fs);
   // return the opened Excel file
   return wb;
  }
  catch(Exception e)
  {
   // if an exception is thrown print the error code to std out
   System.out.println("Error in method openFile: "+e);
  } 
  // if the file couldn't be opened it returns null
  System.out.println("Could not open template:");
  return null;
 }

How is the current situation on this? Has anyone of you had the same Problem and maybe found a solution? Or is there an other method I could use?

Thanks in advance and all the best, 
Meike