コード例 #1
0
ファイル: Workbook.cs プロジェクト: Henry-T/UnityPG
        /**
         * Creates an empty workbook object with three blank sheets and all the empty
         * fields.  Use this to Create a workbook from scratch.
         */
        public static Workbook CreateWorkbook()
        {
            //if (log.Check(POILogger.DEBUG))
            //    log.Log(DEBUG, "creating new workbook from scratch");
            Workbook retval = new Workbook();
            List<Record> records = new List<Record>(30);
            retval.records.Records=records;
            List<FormatRecord> formats = new List<FormatRecord>(8);

            records.Add(retval.CreateBOF());
            records.Add(retval.CreateInterfaceHdr());
            records.Add(retval.CreateMMS());
            records.Add(retval.CreateInterfaceEnd());
            records.Add(retval.CreateWriteAccess());
            records.Add(retval.CreateCodepage());
            records.Add(retval.CreateDSF());
            records.Add(retval.CreateTabId());
            retval.records.Tabpos=records.Count - 1;
            records.Add(retval.CreateFnGroupCount());
            records.Add(retval.CreateWindowProtect());
            records.Add(retval.CreateProtect());
            retval.records.Protpos=records.Count - 1;
            records.Add(retval.CreatePassword());
            records.Add(retval.CreateProtectionRev4());
            records.Add(retval.CreatePasswordRev4());
            retval.windowOne = (WindowOneRecord)retval.CreateWindowOne();
            records.Add(retval.windowOne);
            records.Add(retval.CreateBackup());
            retval.records.Backuppos=records.Count - 1;
            records.Add(retval.CreateHideObj());
            records.Add(retval.CreateDateWindow1904());
            records.Add(retval.CreatePrecision());
            records.Add(retval.CreateRefreshAll());
            records.Add(retval.CreateBookBool());
            records.Add(retval.CreateFont());
            records.Add(retval.CreateFont());
            records.Add(retval.CreateFont());
            records.Add(retval.CreateFont());
            retval.records.Fontpos=records.Count - 1;   // last font record postion
            retval.numfonts = 4;

            // Set up format records
            for (int i = 0; i <= 7; i++)
            {
                Record rec;
                rec = retval.CreateFormat(i);
                retval.maxformatid = retval.maxformatid >= ((FormatRecord)rec).GetIndexCode() ? retval.maxformatid : ((FormatRecord)rec).GetIndexCode();
                formats.Add((FormatRecord)rec);
                records.Add(rec);
            }
            retval.formats = formats;

            for (int k = 0; k < 21; k++)
            {
                records.Add(retval.CreateExtendedFormat(k));
                retval.numxfs++;
            }
            retval.records.Xfpos=records.Count - 1;
            for (int k = 0; k < 6; k++)
            {
                records.Add(retval.CreateStyle(k));
            }
            records.Add(retval.CreateUseSelFS());

            int nBoundSheets = 1; // now just do 1
            for (int k = 0; k < nBoundSheets; k++)
            {
                BoundSheetRecord bsr =
                        (BoundSheetRecord)retval.CreateBoundSheet(k);

                records.Add(bsr);
                retval.boundsheets.Add(bsr);
                retval.records.Bspos=records.Count - 1;
            }
            //        retval.records.supbookpos = retval.records.bspos + 1;
            //        retval.records.namepos = retval.records.supbookpos + 2;
            records.Add(retval.CreateCountry());
            for (int k = 0; k < nBoundSheets; k++)
            {
                retval.OrCreateLinkTable.CheckExternSheet(k);
            }
            retval.sst = (SSTRecord)retval.CreateSST();
            records.Add(retval.sst);
            records.Add(retval.CreateExtendedSST());

            records.Add(retval.CreateEOF());
            //if (log.Check(POILogger.DEBUG))
            //    log.Log(DEBUG, "exit Create new workbook from scratch");
            return retval;
        }