/** * Read all files from a POI filesystem which are property Set streams * and returns them as an array of {@link org.apache.poi.hpsf.PropertySet} * instances. * * @param poiFs The name of the POI filesystem as seen by the * operating system. (This is the "filename".) * * @return The property Sets. The elements are ordered in the same way * as the files in the POI filesystem. * * @exception FileNotFoundException if the file containing the POI * filesystem does not exist * * @exception IOException if an I/O exception occurs */ public static POIFile[] ReadPropertySets(FileInfo poifs) { List <POIFile> files = new List <POIFile>(7); POIFSReader reader2 = new POIFSReader(); //reader2.StreamReaded += new POIFSReaderEventHandler(reader2_StreamReaded); POIFSReaderListener pfl = new POIFSReaderListener1(files); reader2.RegisterListener(pfl); /* Read the POI filesystem. */ FileStream stream = poifs.OpenRead(); try { reader2.Read(stream); } finally { stream.Close(); } POIFile[] result = new POIFile[files.Count]; for (int i = 0; i < result.Length; i++) { result[i] = files[i]; } return(result); }
public void TestPropertySetMethods() { POIDataSamples samples = POIDataSamples.GetHPSFInstance(); using (FileStream data = samples.GetFile(POI_FS)) { POIFile poiFile = Util.ReadPOIFiles(data, POI_FILES)[0]; byte[] b = poiFile.GetBytes(); PropertySet ps = PropertySetFactory.Create(new ByteArrayInputStream(b)); Assert.IsTrue(ps.IsDocumentSummaryInformation, "IsDocumentSummaryInformation"); Assert.AreEqual(ps.SectionCount, 2); Section s = (Section)ps.Sections[1]; Assert.AreEqual(s.GetProperty(1), (int)Constants.CP_UTF16); Assert.AreEqual(s.GetProperty(2), -96070278); Assert.AreEqual(s.GetProperty(3), "MCon_Info zu Office bei Schreiner"); Assert.AreEqual(s.GetProperty(4), "*****@*****.**"); Assert.AreEqual(s.GetProperty(5), "Petrovitsch, Wilhelm"); } }
/** * Reads a Set of files from a POI filesystem and returns them * as an array of {@link POIFile} instances. This method loads all * files into memory and thus does not cope well with large POI * filessystems. * * @param poiFs The name of the POI filesystem as seen by the * operating system. (This is the "filename".) * * @param poiFiles The names of the POI files to be Read. * * @return The POI files. The elements are ordered in the same way * as the files in the POI filesystem. * * @exception FileNotFoundException if the file containing the POI * filesystem does not exist * * @exception IOException if an I/O exception occurs */ public static POIFile[] ReadPOIFiles(Stream poiFs, String[] poiFiles) { files = new ArrayList(); POIFSReader reader1 = new POIFSReader(); //reader1.StreamReaded += new POIFSReaderEventHandler(reader1_StreamReaded); POIFSReaderListener pfl = new POIFSReaderListener0(); if (poiFiles == null) { /* Register the listener for all POI files. */ reader1.RegisterListener(pfl); } else { /* Register the listener for the specified POI files * only. */ for (int i = 0; i < poiFiles.Length; i++) { reader1.RegisterListener(pfl, poiFiles[i]); } } /* Read the POI filesystem. */ reader1.Read(poiFs); POIFile[] result = new POIFile[files.Count]; for (int i = 0; i < result.Length; i++) { result[i] = (POIFile)files[i]; } return(result); }
/** * Read all files from a POI filesystem which are property Set streams * and returns them as an array of {@link org.apache.poi.hpsf.PropertySet} * instances. * * @param poiFs The name of the POI filesystem as seen by the * operating system. (This is the "filename".) * * @return The property Sets. The elements are ordered in the same way * as the files in the POI filesystem. * * @exception FileNotFoundException if the file containing the POI * filesystem does not exist * * @exception IOException if an I/O exception occurs */ public static POIFile[] ReadPropertySets(FileStream poiFs) { files = new ArrayList(7); POIFSReader reader2 = new POIFSReader(); reader2.StreamReaded += new POIFSReaderEventHandler(reader2_StreamReaded); /* Read the POI filesystem. */ reader2.Read(poiFs); POIFile[] result = new POIFile[files.Count]; for (int i = 0; i < result.Length; i++) { result[i] = (POIFile)files[i]; } return(result); }
/** * Reads a Set of files from a POI filesystem and returns them * as an array of {@link POIFile} instances. This method loads all * files into memory and thus does not cope well with large POI * filessystems. * * @param poiFs The name of the POI filesystem as seen by the * operating system. (This is the "filename".) * * @param poiFiles The names of the POI files to be Read. * * @return The POI files. The elements are ordered in the same way * as the files in the POI filesystem. * * @exception FileNotFoundException if the file containing the POI * filesystem does not exist * * @exception IOException if an I/O exception occurs */ public static POIFile[] ReadPOIFiles(Stream poiFs, String[] poiFiles) { files = new ArrayList(); POIFSReader reader1 = new POIFSReader(); reader1.StreamReaded += new POIFSReaderEventHandler(reader1_StreamReaded); /* Read the POI filesystem. */ reader1.Read(poiFs); POIFile[] result = new POIFile[files.Count]; for (int i = 0; i < result.Length; i++) { result[i] = (POIFile)files[i]; } return(result); }
static void reader2_StreamReaded(object sender, POIFSReaderEventArgs e) { POIFile f = new POIFile(); f.SetName(e.Name); f.SetPath(e.Path); Stream in1 = e.Stream; if (PropertySet.IsPropertySetStream(in1)) { MemoryStream out1 = new MemoryStream(); Util.Copy(in1, out1); out1.Close(); f.SetBytes(out1.ToArray()); files.Add(f); } }
public void ProcessPOIFSReaderEvent(POIFSReaderEvent evt) { try { POIFile f = new POIFile(); f.SetName(evt.Name); f.SetPath(evt.Path); MemoryStream out1 = new MemoryStream(); Util.Copy(evt.Stream, out1); out1.Close(); f.SetBytes(out1.ToArray()); files.Add(f); } catch (IOException ex) { throw new RuntimeException(ex.Message); } }
static void reader1_StreamReaded(object sender, POIFSReaderEventArgs e) { try { POIFile f = new POIFile(); f.SetName(e.Name); f.SetPath(e.Path); Stream in1 = e.Stream; MemoryStream out1 = new MemoryStream(); Util.Copy(in1, out1); out1.Close(); f.SetBytes(out1.ToArray()); files.Add(f); } catch (IOException) { throw; } }
public void ProcessPOIFSReaderEvent(POIFSReaderEvent e) { try { POIFile f = new POIFile(); f.SetName(e.Name); f.SetPath(e.Path); Stream in1 = e.Stream; if (PropertySet.IsPropertySetStream(in1)) { using (MemoryStream out1 = new MemoryStream()) { Util.Copy(in1, out1); //out1.Close(); f.SetBytes(out1.ToArray()); files.Add(f); } } } catch (Exception ex) { throw new RuntimeException(ex); } }
/** * Read all files from a POI filesystem which are property Set streams * and returns them as an array of {@link org.apache.poi.hpsf.PropertySet} * instances. * * @param poiFs The name of the POI filesystem as seen by the * operating system. (This is the "filename".) * * @return The property Sets. The elements are ordered in the same way * as the files in the POI filesystem. * * @exception FileNotFoundException if the file containing the POI * filesystem does not exist * * @exception IOException if an I/O exception occurs */ public static POIFile[] ReadPropertySets(FileStream poifs) { files = new ArrayList(7); POIFSReader reader2 = new POIFSReader(); //reader2.StreamReaded += new POIFSReaderEventHandler(reader2_StreamReaded); POIFSReaderListener pfl = new POIFSReaderListener1(); reader2.RegisterListener(pfl); /* Read the POI filesystem. */ reader2.Read(poifs); POIFile[] result = new POIFile[files.Count]; for (int i = 0; i < result.Length; i++) result[i] = (POIFile)files[i]; return result; }
/** * Reads a Set of files from a POI filesystem and returns them * as an array of {@link POIFile} instances. This method loads all * files into memory and thus does not cope well with large POI * filessystems. * * @param poiFs The name of the POI filesystem as seen by the * operating system. (This is the "filename".) * * @param poiFiles The names of the POI files to be Read. * * @return The POI files. The elements are ordered in the same way * as the files in the POI filesystem. * * @exception FileNotFoundException if the file containing the POI * filesystem does not exist * * @exception IOException if an I/O exception occurs */ public static POIFile[] ReadPOIFiles(Stream poiFs, String[] poiFiles) { files = new ArrayList(); POIFSReader reader1 = new POIFSReader(); //reader1.StreamReaded += new POIFSReaderEventHandler(reader1_StreamReaded); POIFSReaderListener pfl = new POIFSReaderListener0(); if (poiFiles == null) /* Register the listener for all POI files. */ reader1.RegisterListener(pfl); else /* Register the listener for the specified POI files * only. */ for (int i = 0; i < poiFiles.Length; i++) reader1.RegisterListener(pfl, poiFiles[i]); /* Read the POI filesystem. */ reader1.Read(poiFs); POIFile[] result = new POIFile[files.Count]; for (int i = 0; i < result.Length; i++) result[i] = (POIFile)files[i]; return result; }