Ejemplo n.º 1
0
        private static void SaveLowLevelXML(AbsXLSRecords records, string fileName, string sourceFileName)
        {
            StreamWriter writer1 = new StreamWriter(fileName);

            if (sourceFileName != null)
            {
                writer1.WriteLine("<!-- FileName: {0} -->", sourceFileName);
            }
            writer1.WriteLine("<ExcelFile>");
            string text1 = null;
            int    num1  = 0;

            foreach (AbsXLSRec rec1 in records)
            {
                if (rec1.Name == text1)
                {
                    num1++;
                }
                else
                {
                    num1  = 0;
                    text1 = rec1.Name;
                }
                writer1.WriteLine(rec1.GetXMLRecord(num1));
            }
            writer1.Write("</ExcelFile>");
            writer1.Close();
        }
Ejemplo n.º 2
0
        private static AbsXLSRecords ReadHelper(string fileName, bool readSummaryStreams, ref byte[] ss, ref byte[] dss)
        {
            StructuredStorageFileBase base1 = StructuredStorageFileBase.Open(fileName);
            MemoryStream stream1            = new MemoryStream(base1.ReadStream("Workbook"));

            if (readSummaryStreams)
            {
                try
                {
                    ss = base1.ReadStream("" + '\x0005' + "SummaryInformation");
                }
                catch
                {
                }
                try
                {
                    dss = base1.ReadStream("" + '\x0005' + "DocumentSummaryInformation");
                }
                catch
                {
                }
            }
            base1.Close();
            BinaryReader  reader1  = new BinaryReader(stream1, new UnicodeEncoding());
            AbsXLSRecords records1 = new AbsXLSRecords();

            records1.Read(reader1);
            reader1.Close();
            stream1.Close();
            return(records1);
        }
Ejemplo n.º 3
0
        public static void DumpToLowLevelXml(string sourceFileName, string destinationFileName)
        {
            byte[]        buffer1  = null;
            AbsXLSRecords records1 = ExcelFile.ReadHelper(sourceFileName, false, ref buffer1, ref buffer1);

            ExcelFile.SaveLowLevelXML(records1, destinationFileName, sourceFileName);
        }
Ejemplo n.º 4
0
        ///<summary>
        ///Loads the existing XLS file (optionally preserving MS Excel records).
        ///</summary>
        ///<remarks>
        ///<p>If the only purpose of loading the file is to read data values and formatting using
        ///ExcelLite API, you should use <i>xlsOptions</i> set to <see cref="MB.WinEIDrive.Excel.XlsOptions.None">XlsOptions.None</see>
        ///as this will speed up the loading process.</p>
        ///<p>If you load the existing file to use it as template for a new file, you can choose
        ///whether you want to preserve specific MS Excel records not recognized by ExcelLite API.</p>
        ///</remarks>
        ///<param name="fileName">Existing XLS file name (opened for reading).</param>
        ///<param name="xlsOptions">XLS options.</param>
        public void LoadXls(string fileName, XlsOptions xlsOptions)
        {
            this.Reset();
            AbsXLSRecords records1 = ExcelFile.ReadHelper(fileName, (xlsOptions & XlsOptions.PreserveSummaries) != XlsOptions.None, ref this.summaryStream, ref this.documentSummaryStream);
            XLSFileReader reader1  = new XLSFileReader(this, xlsOptions);

            reader1.ImportRecords(records1, fileName);
        }
Ejemplo n.º 5
0
        public void WriteRecords(AbsXLSRecords destination, int recordCode)
        {
            ArrayList list1 = (ArrayList)this.typeGroupedRecords[recordCode];

            if (list1 != null)
            {
                foreach (XLSRecord record1 in list1)
                {
                    destination.Add(record1);
                }
            }
        }
Ejemplo n.º 6
0
        private static void SaveXLSInternal(AbsXLSRecords records, string fileName, byte[] ss, byte[] dss)
        {
            StructuredStorageFileBase base1 = StructuredStorageFileBase.Create(fileName);

            base1.WriteStream("Workbook", XLSFileWriter.GetStream(records));
            if (ss != null)
            {
                base1.WriteStream("" + '\x0005' + "SummaryInformation", ss);
            }
            if (dss != null)
            {
                base1.WriteStream("" + '\x0005' + "DocumentSummaryInformation", dss);
            }
            base1.Close();
        }
Ejemplo n.º 7
0
        public void WriteRecords(AbsXLSRecords destination, string recordName)
        {
            int num1 = XLSDescriptors.GetByName(recordName).Code;

            this.WriteRecords(destination, num1);
        }