コード例 #1
0
ファイル: Util.cs プロジェクト: zzy092/npoi
        /**
         * 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);
        }
コード例 #2
0
ファイル: TestUnicode.cs プロジェクト: zuiwanting/npoi
        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");
            }
        }
コード例 #3
0
        /**
         * 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);
        }
コード例 #4
0
ファイル: Util.cs プロジェクト: thinhmascot/NPOI
        /**
         * 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);
        }
コード例 #5
0
ファイル: Util.cs プロジェクト: thinhmascot/NPOI
        /**
         * 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);
        }
コード例 #6
0
ファイル: Util.cs プロジェクト: thinhmascot/NPOI
        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);
            }
        }
コード例 #7
0
ファイル: Util.cs プロジェクト: zzy092/npoi
 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);
     }
 }
コード例 #8
0
ファイル: Util.cs プロジェクト: thinhmascot/NPOI
 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;
     }
 }
コード例 #9
0
ファイル: Util.cs プロジェクト: zzy092/npoi
 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);
     }
 }
コード例 #10
0
ファイル: Util.cs プロジェクト: JnS-Software-LLC/npoi
 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);
     }
 }
コード例 #11
0
ファイル: Util.cs プロジェクト: JnS-Software-LLC/npoi
 /**
  * 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;
 }
コード例 #12
0
ファイル: Util.cs プロジェクト: JnS-Software-LLC/npoi
 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);
     }
 }
コード例 #13
0
ファイル: Util.cs プロジェクト: JnS-Software-LLC/npoi
        /**
         * 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;
        }