private void AssertFailMyXls(string message, string expectedFile, string actualFile) { Ole2Document n2doc = new Ole2Document(); FileStream fs = new FileInfo(actualFile).Open(FileMode.Open, FileAccess.Read); n2doc.Load(fs); fs.Close(); Bytes actualWorksheet = n2doc.Streams[n2doc.Streams.GetIndex(Directory.Biff8Workbook)].Bytes; n2doc = new Ole2Document(); fs = new FileInfo(expectedFile).Open(FileMode.Open, FileAccess.Read); n2doc.Load(fs); fs.Close(); Bytes expectedWorksheet = n2doc.Streams[n2doc.Streams.GetIndex(Directory.Biff8Workbook)].Bytes; string expectedWorksheetFile = "ExpectedWorksheet.records"; string actualWorksheetFile = "ActualWorksheet.records"; WriteRecordsToFile(actualWorksheet, actualWorksheetFile); WriteRecordsToFile(expectedWorksheet, expectedWorksheetFile); Process ueProc = new Process(); ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.FileName = "uedit32"; startInfo.Arguments = string.Format("/a \"{0}\" \"{1}\" \"{2}\" \"{3}\"", expectedFile, actualFile, expectedWorksheetFile, actualWorksheetFile); ueProc.StartInfo = startInfo; ueProc.Start(); Assert.Fail(message); }
public void TestEmptyBlankBiff8Streams() { byte[] stream1Name = new byte[] { 0x57, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6B, 0x00, 0x62, 0x00, 0x6F, 0x00, 0x6F, 0x00, 0x6B, 0x00, 0x00, 0x00 }; byte[] stream2Name = new byte[] { 0x05, 0x00, 0x53, 0x00, 0x75, 0x00, 0x6D, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x72, 0x00, 0x79, 0x00, 0x49, 0x00, 0x6E, 0x00, 0x66, 0x00, 0x6F, 0x00, 0x72, 0x00, 0x6D, 0x00, 0x61, 0x00, 0x74, 0x00, 0x69, 0x00, 0x6F, 0x00, 0x6E, 0x00, 0x00, 0x00 }; byte[] stream1 = GetBytes(TestsConfig.ReferenceFileFolder + "Stream1.bin"); Assert.AreEqual(579, stream1.Length); byte[] stream2 = GetBytes(TestsConfig.ReferenceFileFolder + "Stream2.bin"); Assert.AreEqual(312, stream2.Length); Ole2Document doc = new Ole2Document(); doc.Streams.AddNamed(stream1, stream1Name); doc.Streams.AddNamed(stream2, stream2Name); WriteBytesToFile(doc.Bytes.ByteArray, "test.xls"); Assert.AreEqual(3072, doc.Bytes.Length); }
/// <summary> /// Initializes a new XlsDocument from the provided stream, reading in as much information /// from the file as possible and representing it appropriately with MyXls objects /// (Workbook, Worksheets, Cells, etc.). /// </summary> /// <param name="stream">The stream to read into this XlsDocument.</param> public XlsDocument(System.IO.Stream stream) { if (stream == null) { throw new ArgumentException("Can't be null", "steam"); } _ole2Doc = new Ole2Document(); _ole2Doc.Load(stream); //TODO: SummaryInformationSection and DocumentSummaryInformationSections should be read by MyOle2 _workbook = new Workbook(this, _ole2Doc.Streams[_ole2Doc.Streams.GetIndex(Cn.Vcredit.Common.MyOle2.Directory.Biff8Workbook)].Bytes, null); }
/// <summary> /// Initializes a new instance of the XlsDocument class. /// </summary> public XlsDocument() { _forceStandardOle2Stream = false; _isLittleEndian = true; _ole2Doc = new Ole2Document(); SetOleDefaults(); _summaryInformation = new SummaryInformationSection(); _documentSummaryInformation = new DocumentSummaryInformationSection(); _workbook = new Workbook(this); }
public void TestLoad() { Ole2Document doc = new Ole2Document(); FileInfo fi = new FileInfo(TestsConfig.ReferenceFileFolder + "Book1.xls"); doc.Load(fi.Open(FileMode.Open, FileAccess.Read, FileShare.Read)); Assert.AreEqual(2, doc.Streams.Count, "# Streams"); byte[] refStream1 = GetBytes(TestsConfig.ReferenceFileFolder + "Stream1.bin"); byte[] refStream2 = GetBytes(TestsConfig.ReferenceFileFolder + "Stream2.bin"); byte[] tstStream1 = doc.Streams[1].Bytes.ByteArray; byte[] tstStream2 = doc.Streams[2].Bytes.ByteArray; Assert.AreEqual(refStream1, tstStream1, "Stream 1 ref & test stream bytes"); Assert.AreEqual(refStream2, tstStream2, "Stream 2 ref & test stream bytes"); }
internal XlsDocument(string fileName, Workbook.BytesReadCallback workbookBytesReadCallback) { if (string.IsNullOrEmpty(fileName)) { throw new ArgumentException("Can't be null or Empty", "fileName"); } if (!File.Exists(fileName)) { throw new FileNotFoundException("Excel File not found", fileName); } _ole2Doc = new Ole2Document(); using (FileStream fileStream = File.Open(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) { _ole2Doc.Load(fileStream); } //TODO: SummaryInformationSection and DocumentSummaryInformationSections should be read by MyOle2 _workbook = new Workbook(this, _ole2Doc.Streams[_ole2Doc.Streams.GetIndex(Cn.Vcredit.Common.MyOle2.Directory.Biff8Workbook)].Bytes, workbookBytesReadCallback); }
/// <summary> /// Initializes a new instance of the MetadataStream class for the given parent /// Ole2Document. /// </summary> /// <param name="parentDocument">The parent Ole2Document for which to initialize /// this MetadataStream.</param> public MetadataStream(Ole2Document parentDocument) { _parentDocument = parentDocument; _header = new Header(this); }
// Token: 0x06000089 RID: 137 RVA: 0x00004C7B File Offset: 0x00003C7B public MetadataStream(Ole2Document parentDocument) { this._parentDocument = parentDocument; this._header = new MetadataStream.Header(this); }
public void Instantiate() { #pragma warning disable 168 Ole2Document doc = new Ole2Document(); #pragma warning restore 168 }
/// <summary> /// Initializes a new instance of the MetadataStream class for the given parent /// Ole2Document. /// </summary> /// <param name="parentDocument">The parent Ole2Document for which to initialize /// this MetadataStream.</param> public MetadataStream(Ole2Document parentDocument) { _parentDocument = parentDocument; _header = new Header(this); }