Exemple #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);
            }
Exemple #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);
        }
Exemple #3
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);
        }
Exemple #4
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);
        }
Exemple #5
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);
        }