Exemplo n.º 1
0
        private void SaveToStream(IDataStream DataStream, TSaveData SaveData, int SheetIndex)
        {
            if ((sBOF == null) || (sEOF == null))
            {
                XlsMessages.ThrowException(XlsErr.ErrSectionNotLoaded);
            }

            sBOF.SaveToStream(DataStream, SaveData, 0);
            FileEncryption.SaveFirstPart(DataStream, SaveData); //WriteProt
            if (DataStream.Encryption.Engine != null)           //FilePass
            {
                byte[] Fp = DataStream.Encryption.Engine.GetFilePassRecord();
                DataStream.WriteRaw(Fp, Fp.Length);
            }

            if (IsXltTemplate)
            {
                TTemplateRecord.SaveNewRecord(DataStream);
            }

            FileEncryption.SaveSecondPart(DataStream, SaveData);

            TGlobalRecordSaver g = new TGlobalRecordSaver(DataStream, SaveData);

            g.SaveRecord(CodePage);

            FLel.SaveToStream(DataStream, SaveData, 0);
            TDSFRecord.SaveDSF(DataStream);
            g.SaveRecord(Excel9File);

            if (SheetIndex < 0)
            {
                FBoundSheets.SaveTabIds(DataStream);
            }
            g.SaveRecord(GetMacroRec(ObjProj));
            g.SaveRecord(GetMacroRec(ObNoMacros));
            g.SaveRecord(CodeNameRecord);

            FFnGroups.SaveToStream(DataStream, SaveData, 0);
            g.SaveRecord(OleObjectSize);
            FWorkbookProtection.SaveToStream(DataStream, SaveData);
            foreach (TWindow1Record w1 in Window1)
            {
                g.SaveRecord(w1);
            }
            TBackupRecord.SaveRecord(DataStream, Backup);
            THideObjRecord.SaveRecord(DataStream, HideObj);
            T1904Record.SaveRecord(DataStream, Dates1904);

            TPrecisionRecord.SaveRecord(DataStream, PrecisionAsDisplayed);
            TRefreshAllRecord.SaveRecord(DataStream, RefreshAll);

            g.SaveRecord(BookBool);

            Fonts.SaveToStream(DataStream, SaveData, 0);
            Formats.SaveToStream(DataStream, SaveData, 0);
            StyleXF.SaveAllToStream(DataStream, ref SaveData, CellXF);

            DXF.SaveToStream(DataStream, SaveData, 0);
            Styles.SaveToStream(DataStream, SaveData, 0);
            TableStyles.SaveToStream(DataStream, SaveData, 0);
            g.SaveRecord(Palette);
            g.SaveRecord(ClrtClient);

            PivotCache.SaveToStream(DataStream, SaveData, 0);
            DocRoute.SaveToStream(DataStream, SaveData, 0);

            UserBView.SaveToStream(DataStream, SaveData, 0);
            TUsesELFsRecord.SaveRecord(DataStream, UsesELFs);

            if (SheetIndex < 0)
            {
                FBoundSheets.SaveToStream(DataStream, SaveData);
                MetaData.SaveToStream(DataStream, SaveData, 0);
            }
            else
            {
                FBoundSheets.SaveRangeToStream(DataStream, SaveData, SheetIndex);
            }

            g.SaveRecord(MTRSettings);
            g.SaveRecord(ForceFullCalculation);
            g.SaveRecord(Country);

            FReferences.SaveToStream(DataStream, SaveData);
            FNames.SaveToStream(DataStream, SaveData, 0); //Should be after FBoundSheets.SaveToStream
            RealTimeData.SaveToStream(DataStream, SaveData, 0);
            g.SaveRecord(RecalcId);

            if (SheetIndex < 0)
            {
                FHeaderImages.SaveToStream(DataStream, SaveData);
                FDrawingGroup.SaveToStream(DataStream, SaveData);
            }

            FSST.SaveToStream(DataStream, SaveData);
            WebPub.SaveToStream(DataStream, SaveData, 0);
            g.SaveRecord(WOpt);
            //CrErr is ignored
            g.SaveRecord(BookExt);
            FeatHdr.SaveToStream(DataStream, SaveData, 0);
            DConn.SaveToStream(DataStream, SaveData, 0);
            ThemeRecord.SaveToStream(DataStream, SaveData, 0);
            g.SaveRecord(CompressPictures);
            g.SaveRecord(Compat12);
            g.SaveRecord(GUIDTypeLib);
            FFutureRecords.SaveToStream(DataStream, SaveData, 0);
            sEOF.SaveToStream(DataStream, SaveData, 0);
        }