本文整理汇总了C#中NPOI.POIFS.FileSystem.POIFSFileSystem.CreateDocumentInputStream方法的典型用法代码示例。如果您正苦于以下问题:C# POIFSFileSystem.CreateDocumentInputStream方法的具体用法?C# POIFSFileSystem.CreateDocumentInputStream怎么用?C# POIFSFileSystem.CreateDocumentInputStream使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NPOI.POIFS.FileSystem.POIFSFileSystem
的用法示例。
在下文中一共展示了POIFSFileSystem.CreateDocumentInputStream方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetUp
public void SetUp()
{
POIFSFileSystem filesystem = new POIFSFileSystem(
POIDataSamples.GetDocumentInstance().OpenResourceAsStream("test.doc"));
DocumentEntry documentProps =
(DocumentEntry)filesystem.Root.GetEntry("WordDocument");
_mainStream = new byte[documentProps.Size];
filesystem.CreateDocumentInputStream("WordDocument").Read(_mainStream);
// use the fib to determine the name of the table stream.
_fib = new FileInformationBlock(_mainStream);
String name = "0Table";
if (_fib.IsFWhichTblStm())
{
name = "1Table";
}
// read in the table stream.
DocumentEntry tableProps =
(DocumentEntry)filesystem.Root.GetEntry(name);
_tableStream = new byte[tableProps.Size];
filesystem.CreateDocumentInputStream(name).Read(_tableStream);
_fib.FillVariableFields(_mainStream, _tableStream);
}
示例2: TestRecord
public void TestRecord()
{
POIFSFileSystem fs = new POIFSFileSystem(
HSSFTestDataSamples.OpenSampleFileStream("WithFormattedGraphTitle.xls"));
// Check we can Open the file via usermodel
HSSFWorkbook hssf = new HSSFWorkbook(fs);
// Now process it through eventusermodel, and
// look out for the title records
ChartTitleFormatRecordGrabber grabber = new ChartTitleFormatRecordGrabber();
Stream din = fs.CreateDocumentInputStream("Workbook");
HSSFRequest req = new HSSFRequest();
req.AddListenerForAllRecords(grabber);
HSSFEventFactory factory = new HSSFEventFactory();
factory.ProcessEvents(req, din);
din.Close();
// Should've found one
Assert.AreEqual(1, grabber.chartTitleFormatRecords.Count);
// And it should be of something interesting
AlRunsRecord r =
(AlRunsRecord)grabber.chartTitleFormatRecords[0];
Assert.AreEqual(3, r.GetFormatCount());
}
示例3: TestFail
public void TestFail()
{
Stream is1 = HSSFTestDataSamples.OpenSampleFileStream("Simple.xls");
POIFSFileSystem fs = new POIFSFileSystem(is1);
HSSFWorkbook wb = new HSSFWorkbook(fs);
//set POIFS properties after constructing HSSFWorkbook
//(a piece of code that used to work up to POI 3.0.2)
SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.Create(fs.CreateDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
summary1.Title=(title);
//Write the modified property back to POIFS
fs.Root.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME).Delete();
fs.CreateDocument(summary1.ToStream(), SummaryInformation.DEFAULT_STREAM_NAME);
//save the workbook and read the property
MemoryStream out1 = new MemoryStream();
wb.Write(out1);
out1.Close();
POIFSFileSystem fs2 = new POIFSFileSystem(new MemoryStream(out1.ToArray()));
SummaryInformation summary2 = (SummaryInformation)PropertySetFactory.Create(fs2.CreateDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
//Assert.Failing assertion
Assert.AreEqual(title, summary2.Title);
}
示例4: Main
static void Main(string[] args)
{
FileStream stream = new FileStream("thumbs.db", FileMode.Open, FileAccess.Read);
POIFSFileSystem poifs = new POIFSFileSystem(stream);
var entries = poifs.Root.Entries;
//POIFSDocumentReader catalogdr = poifs.CreatePOIFSDocumentReader("Catalog");
//byte[] b1=new byte[catalogdr.Length-4];
//catalogdr.Read(b1,4,b1.Length);
//Dictionary<string, string> indexList = new Dictionary<string, string>();
//for (int j = 0; j < b1.Length; j++)
//{
// if(b1[0]
//}
while (entries.MoveNext())
{
DocumentNode entry = entries.Current as DocumentNode;
DocumentInputStream dr = poifs.CreateDocumentInputStream(entry.Name);
if (entry.Name.ToLower() == "catalog")
continue;
byte[] buffer = new byte[dr.Length];
dr.Read(buffer);
int startpos = 0;
//detect jfif header
for (int i = 3; i < buffer.Length; i++)
{
if (buffer[i - 3] == 0xFF
&& buffer[i - 2] == 0xD8
&& buffer[i - 1] == 0xFF
&& buffer[i] == 0xE0)
{
startpos = i - 3;
break;
}
}
if (startpos == 0)
continue;
FileStream jpeg = File.Create(entry.Name + ".jpeg");
jpeg.Write(buffer, startpos, buffer.Length - startpos);
jpeg.Close();
}
stream.Close();
}
示例5: CreateFromEmbeddedOleObject
/**
* Creates an instance of this class from an embedded OLE Object. The OLE Object is expected
* to include a stream "{01}Ole10Native" which Contains the actual
* data relevant for this class.
*
* @param poifs POI Filesystem object
* @return Returns an instance of this class
* @throws IOException on IO error
* @throws Ole10NativeException on invalid or unexcepted data format
*/
public static Ole10Native CreateFromEmbeddedOleObject(POIFSFileSystem poifs)
{
bool plain = false;
try
{
poifs.Root.GetEntry("\x0001Ole10ItemName");
plain = true;
}
catch (FileNotFoundException)
{
plain = false;
}
DocumentInputStream dis = poifs.CreateDocumentInputStream(OLE10_NATIVE);
using (MemoryStream bos = new MemoryStream())
{
IOUtils.Copy(dis, bos);
byte[] data = bos.ToArray();
return new Ole10Native(data, 0, plain);
}
}
示例6: TestOK
public void TestOK()
{
Stream is1 = HSSFTestDataSamples.OpenSampleFileStream("Simple.xls");
POIFSFileSystem fs = new POIFSFileSystem(is1);
//set POIFS properties before constructing HSSFWorkbook
SummaryInformation summary1 = (SummaryInformation)PropertySetFactory.Create(fs.CreateDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
summary1.Title = (title);
fs.Root.GetEntry(SummaryInformation.DEFAULT_STREAM_NAME).Delete();
fs.CreateDocument(summary1.ToStream(), SummaryInformation.DEFAULT_STREAM_NAME);
HSSFWorkbook wb = new HSSFWorkbook(fs);
MemoryStream out1 = new MemoryStream();
wb.Write(out1);
out1.Close();
//read the property
POIFSFileSystem fs2 = new POIFSFileSystem(new MemoryStream(out1.ToArray()));
SummaryInformation summary2 = (SummaryInformation)PropertySetFactory.Create(fs2.CreateDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME));
Assert.AreEqual(title, summary2.Title);
}
示例7: 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));
}
示例8: Test56138
public void Test56138()
{
DocumentInputStream dis;
POIFSFileSystem fs =
new POIFSFileSystem(_samples.OpenResourceAsStream("TestZeroLengthCodePage.mpp"));
dis = fs.CreateDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME);
SummaryInformation si = (SummaryInformation)PropertySetFactory.Create(dis);
dis = fs.CreateDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
DocumentSummaryInformation dsi = (DocumentSummaryInformation)PropertySetFactory.Create(dis);
// Test
Assert.AreEqual("MSProject", si.ApplicationName);
Assert.AreEqual("project1", si.Title);
Assert.AreEqual("Jon Iles", si.Author);
Assert.AreEqual("", dsi.Company);
Assert.AreEqual(2, dsi.SectionCount);
}
示例9: Test54233
public void Test54233()
{
DocumentInputStream dis;
POIFSFileSystem fs =
new POIFSFileSystem(_samples.OpenResourceAsStream("TestNon4ByteBoundary.doc"));
dis = fs.CreateDocumentInputStream(SummaryInformation.DEFAULT_STREAM_NAME);
SummaryInformation si = (SummaryInformation)PropertySetFactory.Create(dis);
dis = fs.CreateDocumentInputStream(DocumentSummaryInformation.DEFAULT_STREAM_NAME);
DocumentSummaryInformation dsi = (DocumentSummaryInformation)PropertySetFactory.Create(dis);
// Test
Assert.AreEqual("Microsoft Word 10.0", si.ApplicationName);
Assert.AreEqual("", si.Title);
Assert.AreEqual("", si.Author);
Assert.AreEqual("Cour de Justice", dsi.Company);
// Write out and read back, should still be valid
POIDocument doc = new HPSFPropertiesOnlyDocument(fs);
MemoryStream baos = new MemoryStream();
doc.Write(baos);
MemoryStream bais = new MemoryStream(baos.ToArray());
doc = new HPSFPropertiesOnlyDocument(new POIFSFileSystem(bais));
// Check properties are still there
Assert.AreEqual("Microsoft Word 10.0", si.ApplicationName);
Assert.AreEqual("", si.Title);
Assert.AreEqual("", si.Author);
Assert.AreEqual("Cour de Justice", dsi.Company);
}
示例10: AbortableProcessWorkbookEvents
/// <summary>
/// Processes a file into essentially record events.
/// </summary>
/// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
/// <param name="fs">a POIFS filesystem containing your workbook</param>
/// <returns>numeric user-specified result code.</returns>
public short AbortableProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs)
{
Stream in1 = fs.CreateDocumentInputStream("Workbook");
return AbortableProcessEvents(req, in1);
}
示例11: ProcessWorkbookEvents
/// <summary>
/// Processes a file into essentially record events.
/// </summary>
/// <param name="req">an Instance of HSSFRequest which has your registered listeners</param>
/// <param name="fs">a POIFS filesystem containing your workbook</param>
public void ProcessWorkbookEvents(HSSFRequest req, POIFSFileSystem fs)
{
Stream in1 = fs.CreateDocumentInputStream("Workbook");
ProcessEvents(req, in1);
}