本文整理汇总了C#中NPOI.POIFS.FileSystem.DirectoryNode.CreatePOIFSDocumentReader方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryNode.CreatePOIFSDocumentReader方法的具体用法?C# DirectoryNode.CreatePOIFSDocumentReader怎么用?C# DirectoryNode.CreatePOIFSDocumentReader使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.POIFS.FileSystem.DirectoryNode
的用法示例。
在下文中一共展示了DirectoryNode.CreatePOIFSDocumentReader方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: HSSFWorkbook
/**
* given a POI POIFSFileSystem object, and a specific directory
* within it, read in its Workbook and populate the high and
* low level models. If you're reading in a workbook...start here.
*
* @param directory the POI filesystem directory to process from
* @param preserveNodes whether to preseve other nodes, such as
* macros. This takes more memory, so only say yes if you
* need to. If set, will store all of the POIFSFileSystem
* in memory
* @see org.apache.poi.poifs.filesystem.POIFSFileSystem
* @exception IOException if the stream cannot be read
*/
public HSSFWorkbook(DirectoryNode directory, bool preserveNodes):base(directory)
{
String workbookName = GetWorkbookDirEntryName(directory);
this.preserveNodes = preserveNodes;
// If we're not preserving nodes, don't track the
// POIFS any more
if (!preserveNodes)
{
this.directory = null;
}
_sheets = new List<HSSFSheet>(INITIAL_CAPACITY);
names = new List<HSSFName>(INITIAL_CAPACITY);
// Grab the data from the workbook stream, however
// it happens to be spelled.
Stream stream = directory.CreatePOIFSDocumentReader(workbookName);
List<Record> records = RecordFactory.CreateRecords(stream);
workbook = InternalWorkbook.CreateWorkbook(records);
SetPropertiesFromWorkbook(workbook);
int recOffset = workbook.NumRecords;
// Convert all LabelRecord records to LabelSSTRecord
ConvertLabelRecords(records, recOffset);
RecordStream rs = new RecordStream(records, recOffset);
while (rs.HasNext())
{
InternalSheet sheet = InternalSheet.CreateSheet(rs);
_sheets.Add(new HSSFSheet(this, sheet));
}
for (int i = 0; i < workbook.NumNames; ++i)
{
NameRecord nameRecord = workbook.GetNameRecord(i);
HSSFName name = new HSSFName(this, workbook.GetNameRecord(i), workbook.GetNameCommentRecord(nameRecord));
names.Add(name);
}
}
示例2: 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);
}
/*
//.........这里部分代码省略.........
示例3: 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);
}