本文整理汇总了C#中NPOI.POIFS.FileSystem.NPOIFSFileSystem.WriteFileSystem方法的典型用法代码示例。如果您正苦于以下问题:C# NPOIFSFileSystem.WriteFileSystem方法的具体用法?C# NPOIFSFileSystem.WriteFileSystem怎么用?C# NPOIFSFileSystem.WriteFileSystem使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.POIFS.FileSystem.NPOIFSFileSystem
的用法示例。
在下文中一共展示了NPOIFSFileSystem.WriteFileSystem方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteOutAndReadBack
public static NPOIFSFileSystem WriteOutAndReadBack(NPOIFSFileSystem original)
{
MemoryStream baos = new MemoryStream();
original.WriteFileSystem(baos);
original.Close();
return new NPOIFSFileSystem(new ByteArrayInputStream(baos.ToArray()));
}
示例2: NPOIFSReadCopyWritePOIFSRead
public void NPOIFSReadCopyWritePOIFSRead()
{
FileStream testFile = POIDataSamples.GetSpreadSheetInstance().GetFile("Simple.xls");
NPOIFSFileSystem src = new NPOIFSFileSystem(testFile);
byte[] wbDataExp = IOUtils.ToByteArray(src.CreateDocumentInputStream("Workbook"));
NPOIFSFileSystem nfs = new NPOIFSFileSystem();
EntryUtils.CopyNodes(src.Root, nfs.Root);
src.Close();
MemoryStream bos = new MemoryStream();
nfs.WriteFileSystem(bos);
nfs.Close();
POIFSFileSystem pfs = new POIFSFileSystem(new MemoryStream(bos.ToArray()));
byte[] wbDataAct = IOUtils.ToByteArray(pfs.CreateDocumentInputStream("Workbook"));
Assert.That(wbDataExp, new EqualConstraint(wbDataAct));
}
示例3: WriteOutAndReadHeader
public static HeaderBlock WriteOutAndReadHeader(NPOIFSFileSystem fs)
{
MemoryStream baos = new MemoryStream();
fs.WriteFileSystem(baos);
HeaderBlock header = new HeaderBlock(new MemoryStream(baos.ToArray()));
return header;
}
示例4: TestInPlaceNPOIFSWrite
//.........这里部分代码省略.........
sinf = (SummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(sinfDoc));
Assert.AreEqual(131077, sinf.OSVersion);
dinf = (DocumentSummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(dinfDoc));
Assert.AreEqual(131077, dinf.OSVersion);
// Have them write themselves in-place with no Changes
sinf.Write(new NDocumentOutputStream(sinfDoc));
dinf.Write(new NDocumentOutputStream(dinfDoc));
// And also write to some bytes for Checking
MemoryStream sinfBytes = new MemoryStream();
sinf.Write(sinfBytes);
MemoryStream dinfBytes = new MemoryStream();
dinf.Write(dinfBytes);
// Check that the filesystem can give us back the same bytes
sinfDoc = (DocumentNode)root.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
dinfDoc = (DocumentNode)root.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
byte[] sinfData = IOUtils.ToByteArray(new NDocumentInputStream(sinfDoc));
byte[] dinfData = IOUtils.ToByteArray(new NDocumentInputStream(dinfDoc));
Assert.That(sinfBytes.ToArray(), new EqualConstraint(sinfData));
Assert.That(dinfBytes.ToArray(), new EqualConstraint(dinfData));
// Read back in as-is
sinf = (SummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(sinfDoc));
Assert.AreEqual(131077, sinf.OSVersion);
dinf = (DocumentSummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(dinfDoc));
Assert.AreEqual(131077, dinf.OSVersion);
Assert.AreEqual("Reiichiro Hori", sinf.Author);
Assert.AreEqual("Microsoft Word 9.0", sinf.ApplicationName);
Assert.AreEqual("\u7b2c1\u7ae0", sinf.Title);
Assert.AreEqual("", dinf.Company);
Assert.AreEqual(null, dinf.Manager);
// Now alter a few of them
sinf.Author = (/*setter*/"Changed Author");
sinf.Title = (/*setter*/"Le titre \u00e9tait chang\u00e9");
dinf.Manager = (/*setter*/"Changed Manager");
// Save this into the filesystem
sinf.Write(new NDocumentOutputStream(sinfDoc));
dinf.Write(new NDocumentOutputStream(dinfDoc));
// Read them back in again
sinfDoc = (DocumentNode)root.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
sinf = (SummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(sinfDoc));
Assert.AreEqual(131077, sinf.OSVersion);
dinfDoc = (DocumentNode)root.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
dinf = (DocumentSummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(dinfDoc));
Assert.AreEqual(131077, dinf.OSVersion);
Assert.AreEqual("Changed Author", sinf.Author);
Assert.AreEqual("Microsoft Word 9.0", sinf.ApplicationName);
Assert.AreEqual("Le titre \u00e9tait chang\u00e9", sinf.Title);
Assert.AreEqual("", dinf.Company);
Assert.AreEqual("Changed Manager", dinf.Manager);
// Close the whole filesystem, and open it once more
fs.WriteFileSystem();
fs.Close();
fs = new NPOIFSFileSystem(new FileStream(copy.FullName, FileMode.Open));
root = fs.Root;
// Re-check on load
sinfDoc = (DocumentNode)root.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME);
sinf = (SummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(sinfDoc));
Assert.AreEqual(131077, sinf.OSVersion);
dinfDoc = (DocumentNode)root.GetEntry(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
dinf = (DocumentSummaryInformation)PropertySetFactory.Create(new NDocumentInputStream(dinfDoc));
Assert.AreEqual(131077, dinf.OSVersion);
Assert.AreEqual("Changed Author", sinf.Author);
Assert.AreEqual("Microsoft Word 9.0", sinf.ApplicationName);
Assert.AreEqual("Le titre \u00e9tait chang\u00e9", sinf.Title);
Assert.AreEqual("", dinf.Company);
Assert.AreEqual("Changed Manager", dinf.Manager);
// Tidy up
fs.Close();
copy.Delete();
}