Esempio n. 1
0
        public void TestReadCustomPropertiesFromFiles()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles("Test*.*");

            for (int i = 0; i < files.Length; i++)
            {
                if (TestReadAllFiles.checkExclude(files[i]))
                {
                    continue;
                }
                using (FileStream file = new FileStream(files[i], FileMode.Open, FileAccess.Read))
                {
                    try
                    {
                        RunTest(file);
                    }
                    catch (Exception e)
                    {
                        throw new IOException("While handling file " + files[i], e);
                    }
                }
            }
        }
Esempio n. 2
0
 public void TestRecreate()
 {
     string[] files = _samples.GetFiles();
     for (int i = 0; i < files.Length; i++)
     {
         string filename = Path.GetFileName(files[i]);
         if (filename.StartsWith("Test") && TestReadAllFiles.checkExclude(filename))
         {
             try
             {
                 TestRecreate(new FileInfo(files[i]));
             }
             catch (Exception e)
             {
                 throw new IOException("While handling file " + files[i], e);
             }
         }
     }
 }
Esempio n. 3
0
        public void TestRecreate()
        {
            string[] files = _samples.GetFiles();
            for (int i = 0; i < files.Length; i++)
            {
                string filename = Path.GetFileName(files[i]);
                if (filename.StartsWith("Test") && TestReadAllFiles.checkExclude(filename))
                {
                    //if (files[i].EndsWith("1")
                    //    || files[i].EndsWith("TestHPSFWritingFunctionality.doc")
                    //    || files[i].EndsWith("excel_with_embeded.xls"))
                    //    continue;

                    try
                    {
                        TestRecreate(new FileInfo(files[i]));
                    }
                    catch (Exception e)
                    {
                        throw new IOException("While handling file " + files[i], e);
                    }
                }
            }
        }
Esempio n. 4
0
        public void TestReadDocumentSummaryInformation()
        {
            POIDataSamples _samples = POIDataSamples.GetHPSFInstance();

            string[] files = _samples.GetFiles("Test*.*");

            for (int i = 0; i < files.Length; i++)
            {
                if (!TestReadAllFiles.checkExclude(files[i]))
                {
                    continue;
                }
                using (FileStream doc = new FileStream(files[i], FileMode.Open, FileAccess.Read))
                {
                    Console.WriteLine("Reading file " + doc);
                    try
                    {
                        /* Read a Test document <em>doc</em> into a POI filesystem. */
                        POIFSFileSystem poifs    = new POIFSFileSystem(doc);
                        DirectoryEntry  dir      = poifs.Root;
                        DocumentEntry   dsiEntry = null;
                        try
                        {
                            dsiEntry = (DocumentEntry)dir.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
                        }
                        catch (FileNotFoundException)
                        {
                            /*
                             * A missing document summary information stream is not an error
                             * and therefore silently ignored here.
                             */
                        }
                        //catch (System.IO.IOException ex)
                        //{
                        //     // The process cannot access the file 'testcases\test-data\hpsf\TestUnicode.xls' because it is being used by another process.
                        //    Console.Error.WriteLine("Exception ignored (because some other test cases may read this file, too): " + ex.Message);
                        //}

                        /*
                         * If there is a document summry information stream, Read it from
                         * the POI filesystem.
                         */
                        if (dsiEntry != null)
                        {
                            DocumentInputStream        dis = new DocumentInputStream(dsiEntry);
                            PropertySet                ps  = new PropertySet(dis);
                            DocumentSummaryInformation dsi = new DocumentSummaryInformation(ps);

                            /* Execute the Get... methods. */
                            Console.WriteLine(dsi.ByteCount);
                            Console.WriteLine(dsi.ByteOrder);
                            Console.WriteLine(dsi.Category);
                            Console.WriteLine(dsi.Company);
                            Console.WriteLine(dsi.CustomProperties);
                            // FIXME Console.WriteLine(dsi.Docparts);
                            // FIXME Console.WriteLine(dsi.HeadingPair);
                            Console.WriteLine(dsi.HiddenCount);
                            Console.WriteLine(dsi.LineCount);
                            Console.WriteLine(dsi.LinksDirty);
                            Console.WriteLine(dsi.Manager);
                            Console.WriteLine(dsi.MMClipCount);
                            Console.WriteLine(dsi.NoteCount);
                            Console.WriteLine(dsi.ParCount);
                            Console.WriteLine(dsi.PresentationFormat);
                            Console.WriteLine(dsi.Scale);
                            Console.WriteLine(dsi.SlideCount);
                        }
                    }
                    catch (Exception e)
                    {
                        throw new IOException("While handling file " + files[i], e);
                    }
                }
            }
        }