Example #1
0
            private void AssertFailMyXls(string message, string expectedFile, string actualFile)
            {
                MyOle2.Ole2Document n2doc = new MyOle2.Ole2Document();
                n2doc.Load(new FileInfo(actualFile).Open(FileMode.Open, FileAccess.Read));
                Bytes actualWorksheet = n2doc.Streams[2].Bytes;

                n2doc = new MyOle2.Ole2Document();
                n2doc.Load(new FileInfo(expectedFile).Open(FileMode.Open, FileAccess.Read));
                Bytes  expectedWorksheet     = n2doc.Streams[2].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);
            }
Example #2
0
        /// <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", "stream");

            _ole2Doc = new Ole2Document();
            _ole2Doc.Load(stream);

            //TODO: SummaryInformationSection and DocumentSummaryInformationSections should be read by MyOle2
            _workbook = new Workbook(this, _ole2Doc.Streams[_ole2Doc.Streams.GetIndex(org.in2bits.MyOle2.Directory.Biff8Workbook)].Bytes, null);
        }
Example #3
0
        /// <summary>
        /// Initializes a new instance of the XlsDocument class.
        /// </summary>
        public XlsDocument()
        {
            _forceStandardOle2Stream = false;
            _isLittleEndian          = true;

            _ole2Doc = new MyOle2.Ole2Document();
            SetOleDefaults();

            _workbook = new Workbook(this);

            _summaryInformation = new SummaryInformation(this);
        }
Example #4
0
        /// <summary>
        /// Initializes a new instance of the XlsDocument class.
        /// </summary>
        public XlsDocument()
        {
            _forceStandardOle2Stream = false;
            _isLittleEndian = true;

            _ole2Doc = new MyOle2.Ole2Document();
            SetOleDefaults();

            _summaryInformation = new SummaryInformationSection();
            _documentSummaryInformation = new DocumentSummaryInformationSection();

            _workbook = new Workbook(this);
        }
Example #5
0
        /// <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", "stream");
            }

            _ole2Doc = new Ole2Document();
            _ole2Doc.Load(stream);

            //TODO: SummaryInformationSection and DocumentSummaryInformationSections should be read by MyOle2
            _workbook = new Workbook(this, _ole2Doc.Streams[_ole2Doc.Streams.GetIndex(org.in2bits.MyOle2.Directory.Biff8Workbook)].Bytes, null);
        }
Example #6
0
        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(org.in2bits.MyOle2.Directory.Biff8Workbook)].Bytes, workbookBytesReadCallback);
        }
Example #7
0
        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))
            #if SILVERLIGHT
                throw new FileNotFoundException(string.Format("Excel File not found: {0}", fileName));
            #else
                throw new FileNotFoundException("Excel File not found", fileName);
            #endif

            _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(org.in2bits.MyOle2.Directory.Biff8Workbook)].Bytes, workbookBytesReadCallback);
        }