當前位置: 首頁>>代碼示例>>C#>>正文


C# DirectoryNode.GetEntry方法代碼示例

本文整理匯總了C#中NPOI.POIFS.FileSystem.DirectoryNode.GetEntry方法的典型用法代碼示例。如果您正苦於以下問題:C# DirectoryNode.GetEntry方法的具體用法?C# DirectoryNode.GetEntry怎麽用?C# DirectoryNode.GetEntry使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在NPOI.POIFS.FileSystem.DirectoryNode的用法示例。


在下文中一共展示了DirectoryNode.GetEntry方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: CreateFromEmbeddedOleObject

        /// <summary>
        /// Creates an instance of this class from an embedded OLE Object. The OLE Object is expected
        /// to include a stream &quot;{01}Ole10Native&quot; which contains the actual
        /// data relevant for this class.
        /// </summary>
        /// <param name="directory">directory POI Filesystem object</param>
        /// <returns>Returns an instance of this class</returns>
        public static Ole10Native CreateFromEmbeddedOleObject(DirectoryNode directory)
        {
            bool plain = false;

            try
            {
                directory.GetEntry("\u0001Ole10ItemName");
                plain = true;
            }
            catch (FileNotFoundException)
            {
                plain = false;
            }

            DocumentEntry nativeEntry =
               (DocumentEntry)directory.GetEntry(OLE10_NATIVE);
            byte[] data = new byte[nativeEntry.Size];
            directory.CreateDocumentInputStream(nativeEntry).Read(data);

            return new Ole10Native(data, 0, plain);
        }
開發者ID:89sos98,項目名稱:npoi,代碼行數:28,代碼來源:Ole10Native.cs

示例2: HasEntry

 private bool HasEntry(DirectoryNode dirNode, String entryName)
 {
     try
     {
         dirNode.GetEntry(entryName);
         return true;
     }
     catch (FileNotFoundException)
     {
         return false;
     }
 }
開發者ID:mdjasim,項目名稱:npoi,代碼行數:12,代碼來源:TestHSSFWorkbook.cs

示例3: HWPFDocument

        /// <summary>
        /// Initializes a new instance of the <see cref="HWPFDocument"/> class.
        /// </summary>
        /// <param name="directory">The directory.</param>
        public HWPFDocument(DirectoryNode directory)
            : base(directory)
        {
            _endnotes = new NotesImpl(_endnotesTables);
            _footnotes = new NotesImpl(_footnotesTables);

            // Load the main stream and FIB
            // Also handles HPSF bits

            // Do the CP Split
            _cpSplit = new CPSplitCalculator(_fib);

            // Is this document too old for us?
            if (_fib.GetNFib() < 106)
            {
                throw new OldWordFileFormatException("The document is too old - Word 95 or older. Try HWPFOldDocument instead?");
            }

            // use the fib to determine the name of the table stream.
            String name = "0Table";
            if (_fib.IsFWhichTblStm())
            {
                name = "1Table";
            }

            // Grab the table stream.
            DocumentEntry tableProps;
            try
            {
                tableProps =
                    (DocumentEntry)directory.GetEntry(name);
            }
            catch (FileNotFoundException)
            {
                throw new InvalidOperationException("Table Stream '" + name + "' wasn't found - Either the document is corrupt, or is Word95 (or earlier)");
            }

            // read in the table stream.
            _tableStream = new byte[tableProps.Size];
            directory.CreatePOIFSDocumentReader(name).Read(_tableStream);

            _fib.FillVariableFields(_mainStream, _tableStream);

            // read in the data stream.
            try
            {
                DocumentEntry dataProps =
                    (DocumentEntry)directory.GetEntry("Data");
                _dataStream = new byte[dataProps.Size];
                directory.CreatePOIFSDocumentReader("Data").Read(_dataStream);
            }
            catch (FileNotFoundException)
            {
                _dataStream = new byte[0];
            }

            // Get the cp of the start of text in the main stream
            // The latest spec doc says this is always zero!
            int fcMin = 0;
            //fcMin = _fib.GetFcMin()

            // Start to load up our standard structures.
            _dop = new DocumentProperties(_tableStream, _fib.GetFcDop());
            _cft = new ComplexFileTable(_mainStream, _tableStream, _fib.GetFcClx(), fcMin);
            TextPieceTable _tpt = _cft.GetTextPieceTable();


            // Now load the rest of the properties, which need to be adjusted
            //  for where text really begin
            _cbt = new CHPBinTable(_mainStream, _tableStream, _fib.GetFcPlcfbteChpx(), _fib.GetLcbPlcfbteChpx(), _tpt);
            _pbt = new PAPBinTable(_mainStream, _tableStream, _dataStream, _fib.GetFcPlcfbtePapx(), _fib.GetLcbPlcfbtePapx(), _tpt);

            _text = _tpt.Text;

            /*
 * in this mode we preserving PAPX/CHPX structure from file, so text may
 * miss from output, and text order may be corrupted
 */
            bool preserveBinTables = false;
            try
            {
                preserveBinTables = Boolean.Parse(
                    ConfigurationManager.AppSettings[PROPERTY_PRESERVE_BIN_TABLES]);
            }
            catch (Exception)
            {
                // ignore;
            }

            if (!preserveBinTables)
            {
                _cbt.Rebuild(_cft);
                _pbt.Rebuild(_text, _cft);
            }

            /*
//.........這裏部分代碼省略.........
開發者ID:ctddjyds,項目名稱:npoi,代碼行數:101,代碼來源:HWPFDocument.cs

示例4: GetWorkbookDirEntryName

        private static String GetWorkbookDirEntryName(DirectoryNode directory)
        {

            String[] potentialNames = WORKBOOK_DIR_ENTRY_NAMES;
            for (int i = 0; i < potentialNames.Length; i++)
            {
                String wbName = potentialNames[i];
                try
                {
                    directory.GetEntry(wbName);
                    return wbName;
                }
                catch (FileNotFoundException)
                {
                    // continue - to try other options
                }
            }

            // Check for previous version of file format
            try
            {
                directory.GetEntry("Book");
                throw new OldExcelFormatException("The supplied spreadsheet seems to be Excel 5.0/7.0 (BIFF5) format. "
                        + "POI only supports BIFF8 format (from Excel versions 97/2000/XP/2003)");
            }
            catch (FileNotFoundException)
            {
                // fall through
            }

            throw new ArgumentException("The supplied POIFSFileSystem does not contain a BIFF8 'Workbook' entry. "
                + "Is it really an excel file?");
        }
開發者ID:xiepeixing,項目名稱:npoi,代碼行數:33,代碼來源:HSSFWorkbook.cs

示例5: Open

        private void Open(DirectoryNode directory)
        {
            DocumentNode book = (DocumentNode)directory.GetEntry("Book");
            if (book == null)
            {
                throw new IOException("No Excel 5/95 Book stream found");
            }

            ris = new RecordInputStream(directory.CreateDocumentInputStream(book));
            Prepare();
        }
開發者ID:age-soft,項目名稱:npoi,代碼行數:11,代碼來源:OldExcelExtractor.cs

示例6: HWPFDocumentCore

        /// <summary>
        /// This constructor loads a Word document from a specific point in a POIFSFileSystem, probably not the default.Used typically to open embeded documents.
        /// </summary>
        /// <param name="directory">The POIFSFileSystem that Contains the Word document.</param>
        /// <param name="pfilesystem">If there is an unexpected IOException from the passed in POIFSFileSystem.</param>
        public HWPFDocumentCore(DirectoryNode directory)
            : base(directory)
        {
            // Sort out the hpsf properties


            // read in the main stream.
            DocumentEntry documentProps = (DocumentEntry)
               directory.GetEntry(STREAM_WORD_DOCUMENT);
            _mainStream = new byte[documentProps.Size];

            directory.CreatePOIFSDocumentReader(STREAM_WORD_DOCUMENT).Read(_mainStream);

            // Create our FIB, and check for the doc being encrypted
            _fib = new FileInformationBlock(_mainStream);
            if (_fib.IsFEncrypted())
            {
                throw new EncryptedDocumentException("Cannot process encrypted word files!");
            }

            DirectoryEntry objectPoolEntry;
            try
            {
                objectPoolEntry = (DirectoryEntry)directory.GetEntry(STREAM_OBJECT_POOL);
            }
            catch (FileNotFoundException exc)
            {
                objectPoolEntry = null;
            }
            _objectPool = new ObjectPoolImpl(objectPoolEntry);
        }
開發者ID:xoposhiy,項目名稱:npoi,代碼行數:36,代碼來源:HWPFDocumentCore.cs

示例7: TestEmptyConstructor

        public void TestEmptyConstructor()
        {
            POIFSFileSystem fs = new POIFSFileSystem();
            DirectoryProperty property1 = new DirectoryProperty("parent");
            DirectoryProperty property2 = new DirectoryProperty("child");
            DirectoryNode parent = new DirectoryNode(property1, fs, null);
            DirectoryNode node = new DirectoryNode(property2, fs, parent);

            Assert.AreEqual(0, parent.Path.Length);
            Assert.AreEqual(1, node.Path.Length);
            Assert.AreEqual("child", node.Path.GetComponent(0));

            // Verify that GetEntries behaves correctly
            int count = 0;
            IEnumerator iter = node.Entries;

            while (iter.MoveNext())
            {
                count++;
            }
            Assert.AreEqual(0, count);

            // Verify behavior of IsEmpty
            Assert.IsTrue(node.IsEmpty);

            // Verify behavior of EntryCount
            Assert.AreEqual(0, node.EntryCount);

            // Verify behavior of Entry
            try
            {
                node.GetEntry("foo");
                Assert.Fail("Should have caught FileNotFoundException");
            }
            catch (FileNotFoundException )
            {

                // as expected
            }

            // Verify behavior of isDirectoryEntry
            Assert.IsTrue(node.IsDirectoryEntry);

            // Verify behavior of GetName
            Assert.AreEqual(property2.Name, node.Name);

            // Verify behavior of isDocumentEntry
            Assert.IsTrue(!node.IsDocumentEntry);

            // Verify behavior of GetParent
            Assert.AreEqual(parent, node.Parent);
        }
開發者ID:89sos98,項目名稱:npoi,代碼行數:52,代碼來源:TestDirectoryNode.cs

示例8: TestNonEmptyConstructor

        public void TestNonEmptyConstructor()
        {
            DirectoryProperty property1 = new DirectoryProperty("parent");
            DirectoryProperty property2 = new DirectoryProperty("child1");

            property1.AddChild(property2);
            property1.AddChild(new DocumentProperty("child2", 2000));
            property2.AddChild(new DocumentProperty("child3", 30000));
            DirectoryNode node = new DirectoryNode(property1, new POIFSFileSystem(), null);

            // Verify that GetEntries behaves correctly
            int count = 0;
            IEnumerator iter = node.Entries;

            while (iter.MoveNext())
            {
                count++;
                //iter.Current;
            }
            Assert.AreEqual(2, count);

            // Verify behavior of IsEmpty
            Assert.IsTrue(!node.IsEmpty);

            // Verify behavior of EntryCount
            Assert.AreEqual(2, node.EntryCount);

            // Verify behavior of Entry
            DirectoryNode child1 = (DirectoryNode)node.GetEntry("child1");

            child1.GetEntry("child3");
            node.GetEntry("child2");
            try
            {
                node.GetEntry("child3");
                Assert.Fail("Should have caught FileNotFoundException");
            }
            catch (FileNotFoundException)
            {

                // as expected
            }

            // Verify behavior of isDirectoryEntry
            Assert.IsTrue(node.IsDirectoryEntry);

            // Verify behavior of GetName
            Assert.AreEqual(property1.Name, node.Name);

            // Verify behavior of isDocumentEntry
            Assert.IsTrue(!node.IsDocumentEntry);

            // Verify behavior of GetParent
            Assert.IsNull(node.Parent);
        }
開發者ID:89sos98,項目名稱:npoi,代碼行數:55,代碼來源:TestDirectoryNode.cs

示例9: CreateFromEmbeddedOleObject

        /// <summary>
        /// Creates an instance of this class from an embedded OLE Object. The OLE Object is expected
        /// to include a stream &quot;{01}Ole10Native&quot; which contains the actual
        /// data relevant for this class.
        /// </summary>
        /// <param name="directory">directory POI Filesystem object</param>
        /// <returns>Returns an instance of this class</returns>
        public static Ole10Native CreateFromEmbeddedOleObject(DirectoryNode directory)
        {
            DocumentEntry nativeEntry =
               (DocumentEntry)directory.GetEntry(OLE10_NATIVE);
            byte[] data = new byte[nativeEntry.Size];
            directory.CreateDocumentInputStream(nativeEntry).Read(data);

            return new Ole10Native(data, 0);
        }
開發者ID:Reinakumiko,項目名稱:npoi,代碼行數:16,代碼來源:Ole10Native.cs


注:本文中的NPOI.POIFS.FileSystem.DirectoryNode.GetEntry方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。