Ejemplo n.º 1
0
        public static AbsXLSRec Read(BinaryReader br, AbsXLSRec previousRecord)
        {
            int num1 = br.ReadUInt16();

            if (num1 == 0)
            {
                return(null);
            }
            int           num2        = br.ReadUInt16();
            XLSDescriptor descriptor1 = XLSDescriptors.GetByCode(num1);

            if (!XLSDescriptors.ValidBodySize(descriptor1, num2, false))
            {
                descriptor1 = null;
            }
            if ((descriptor1 != null) && (descriptor1.Name == "FILEPASS"))
            {
                throw new Exception("Current version of ExcelLite can't read encrypted workbooks. You can use only simple password protection against modifying (set in MS Excel 'Save As' dialog).");
            }
            if ((descriptor1 != null) && (descriptor1.HandlerClass != typeof(XLSRecord)))
            {
                object[] objArray1 = new object[] { num2, br, previousRecord };
                return((AbsXLSRec)Activator.CreateInstance(descriptor1.HandlerClass, objArray1));
            }
            return(new XLSRecord(num1, num2, br));
        }
Ejemplo n.º 2
0
        public static bool ValidBodySize(XLSDescriptor des, int size, bool exception)
        {
            if (((des == null) || !des.IsFixedSize) || (des.BodySize == size))
            {
                return(true);
            }
            object[] objArray1 = new object[] { "Record should have size ", des.BodySize, " and not ", size, "." };
            string   text1     = string.Concat(objArray1);

            if (exception)
            {
                throw new Exception("Internal error: " + text1);
            }
            return(false);
        }
Ejemplo n.º 3
0
 // Methods
 static XLSDescriptors()
 {
     XLSDescriptors.name2Descriptor = new Hashtable();
     XLSDescriptors.code2Descriptor = new Hashtable();
     XLSDescriptor[] descriptorArray1 = new XLSDescriptor[0x5c];
     object[]        objArray1        = new object[] { "00 06", typeof(BOFSubstreamType), "BB 0D", "CC 07", "00 00 00 00", "00 06 00 00" };
     descriptorArray1[0] = new XLSDescriptor("BOF", 0x809, 0x10, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(ushort) };
     descriptorArray1[1] = new XLSDescriptor("Protect", 0x12, 2, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(DefaultRowHeightOptions), typeof(ushort) };
     descriptorArray1[2] = new XLSDescriptor("DefaultRowHeight", 0x225, 4, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(ushort) };
     descriptorArray1[3] = new XLSDescriptor("DefaultColumnWidth", 0x55, 2, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort), typeof(Window1Options), typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort) };
     descriptorArray1[4] = new XLSDescriptor("Window1", 0x3d, 0x12, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(ushort), typeof(FontOptions), typeof(ushort), typeof(ushort), typeof(ushort), typeof(byte), "00", "00", "00", typeof(ExcelShortString) };
     descriptorArray1[5] = new XLSDescriptor("Font", 0x31, -1, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(ushort), typeof(ExcelLongString) };
     descriptorArray1[6] = new XLSDescriptor("Format", 0x41e, -1, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(ushort), typeof(ushort), typeof(XFOptions1), typeof(byte), typeof(byte), typeof(ushort), typeof(ushort), typeof(ushort), typeof(uint), typeof(ushort) };
     descriptorArray1[7] = new XLSDescriptor("XF", 0xe0, 20, typeof(XLSRecord), objArray1);
     objArray1           = new object[] { typeof(ushort), typeof(byte), typeof(byte) };
     descriptorArray1[8] = new XLSDescriptor("Style", 0x293, -1, typeof(StyleRecord), objArray1);
     objArray1           = new object[2];
     objArray1[0]        = typeof(ushort);
     object[] objArray2 = new object[] { typeof(byte), typeof(byte), typeof(byte), typeof(byte) };
     objArray1[1]           = objArray2;
     descriptorArray1[9]    = new XLSDescriptor("Palette", 0x92, -1, typeof(PaletteRecord), objArray1);
     objArray1              = new object[5];
     objArray1[0]           = "00 00 00 00";
     objArray1[1]           = typeof(uint);
     objArray1[2]           = typeof(uint);
     objArray1[3]           = "00 00 00 00";
     objArray2              = new object[] { typeof(uint) };
     objArray1[4]           = objArray2;
     descriptorArray1[10]   = new XLSDescriptor("Index", 0x20b, -1, typeof(IndexRecord), objArray1);
     objArray1              = new object[] { typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort), typeof(ColumnInfoOptions), "00 00" };
     descriptorArray1[11]   = new XLSDescriptor("ColumnInfo", 0x7d, 12, typeof(XLSRecord), objArray1);
     objArray1              = new object[] { typeof(uint), typeof(uint), typeof(ushort), typeof(ushort), "00 00" };
     descriptorArray1[12]   = new XLSDescriptor("Dimensions", 0x200, 14, typeof(XLSRecord), objArray1);
     objArray1              = new object[] { typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort), "00 00", "00 00", typeof(RowOptions), typeof(ushort) };
     descriptorArray1[13]   = new XLSDescriptor("Row", 520, 0x10, typeof(XLSRecord), objArray1);
     objArray1              = new object[] { typeof(CellRecordHeader), typeof(uint) };
     descriptorArray1[14]   = new XLSDescriptor("LabelSST", 0xfd, 10, typeof(XLSRecord), objArray1);
     objArray1              = new object[] { typeof(CellRecordHeader) };
     descriptorArray1[15]   = new XLSDescriptor("Blank", 0x201, 6, typeof(XLSRecord), objArray1);
     objArray1              = new object[4];
     objArray1[0]           = typeof(ushort);
     objArray1[1]           = typeof(ushort);
     objArray2              = new object[] { typeof(ushort) };
     objArray1[2]           = objArray2;
     objArray1[3]           = typeof(ushort);
     descriptorArray1[0x10] = new XLSDescriptor("MulBlank", 190, -1, typeof(MulBlankRecord), objArray1);
     objArray1              = new object[2];
     objArray1[0]           = typeof(uint);
     objArray2              = new object[] { typeof(ushort) };
     objArray1[1]           = objArray2;
     descriptorArray1[0x11] = new XLSDescriptor("DBCell", 0xd7, -1, typeof(DBCellRecord), objArray1);
     objArray1              = new object[] { typeof(CellRecordHeader), typeof(uint) };
     descriptorArray1[0x12] = new XLSDescriptor("RK", 0x27e, 10, typeof(RKRecord), objArray1);
     objArray1              = new object[4];
     objArray1[0]           = typeof(ushort);
     objArray1[1]           = typeof(ushort);
     objArray2              = new object[] { typeof(ushort), typeof(uint) };
     objArray1[2]           = objArray2;
     objArray1[3]           = typeof(ushort);
     descriptorArray1[0x13] = new XLSDescriptor("MulRK", 0xbd, -1, typeof(MulRKRecord), objArray1);
     objArray1              = new object[] { typeof(CellRecordHeader), typeof(double) };
     descriptorArray1[20]   = new XLSDescriptor("Number", 0x203, 14, typeof(XLSRecord), objArray1);
     objArray1              = new object[6];
     objArray1[0]           = typeof(CellRecordHeader);
     objArray2              = new object[] { typeof(byte) };
     objArray1[1]           = objArray2;
     objArray1[2]           = typeof(FormulaOptions);
     objArray1[3]           = "00 00 00 00";
     objArray1[4]           = typeof(ushort);
     objArray2              = new object[] { typeof(byte) };
     objArray1[5]           = objArray2;
     descriptorArray1[0x15] = new XLSDescriptor("Formula", 6, -1, typeof(FormulaRecord), objArray1);
     objArray1              = new object[] { typeof(uint), typeof(BoundSheetVisibility), typeof(BoundSheetSheetType), typeof(ExcelShortString) };
     descriptorArray1[0x16] = new XLSDescriptor("BoundSheet", 0x85, -1, typeof(BoundSheetRecord), objArray1);
     objArray1              = new object[] { typeof(uint), typeof(uint), typeof(ExcelLongStrings) };
     descriptorArray1[0x17] = new XLSDescriptor("SST", 0xfc, -1, typeof(SSTRecord), objArray1);
     objArray1              = new object[] { typeof(ExcelLongStrings) };
     descriptorArray1[0x18] = new XLSDescriptor("Continue", 60, -1, typeof(ContinueRecord), objArray1);
     objArray1              = new object[2];
     objArray1[0]           = typeof(ushort);
     objArray2              = new object[] { typeof(uint), typeof(ushort), "00 00" };
     objArray1[1]           = objArray2;
     descriptorArray1[0x19] = new XLSDescriptor("ExtSST", 0xff, -1, typeof(ExtSSTRecord), objArray1);
     objArray1              = new object[] { typeof(WorksheetWindowOptions), typeof(ushort), typeof(ushort), typeof(ushort), "00 00", typeof(ushort), typeof(ushort), "00 00 00 00" };
     descriptorArray1[0x1a] = new XLSDescriptor("Window2", 0x23e, 0x12, typeof(XLSRecord), objArray1);
     objArray1              = new object[2];
     objArray1[0]           = typeof(ushort);
     objArray2              = new object[] { typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort) };
     objArray1[1]           = objArray2;
     descriptorArray1[0x1b] = new XLSDescriptor("MergedCells", 0xe5, -1, typeof(MergedCellsRecord), objArray1);
     objArray1              = new object[] { typeof(WSBoolOptions) };
     descriptorArray1[0x1c] = new XLSDescriptor("WSBool", 0x81, 2, typeof(XLSRecord), objArray1);
     objArray1              = new object[] { typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort) };
     descriptorArray1[0x1d] = new XLSDescriptor("Guts", 0x80, 8, typeof(XLSRecord), objArray1);
     objArray1              = new object[2];
     objArray1[0]           = typeof(ushort);
     objArray2              = new object[] { typeof(ushort), typeof(ushort), typeof(ushort) };
     objArray1[1]           = objArray2;
     descriptorArray1[30]   = new XLSDescriptor("HORIZONTALPAGEBREAKS", 0x1b, -1, typeof(HorizontalPageBreaksRecord), objArray1);
     objArray1              = new object[2];
     objArray1[0]           = typeof(ushort);
     objArray2              = new object[] { typeof(ushort), typeof(ushort), typeof(ushort) };
     objArray1[1]           = objArray2;
     descriptorArray1[0x1f] = new XLSDescriptor("VERTICALPAGEBREAKS", 0x1a, -1, typeof(VerticalPageBreaksRecord), objArray1);
     objArray1              = new object[] { typeof(ushort), typeof(ushort) };
     descriptorArray1[0x20] = new XLSDescriptor("SCL", 160, 4, typeof(XLSRecord), objArray1);
     objArray1              = new object[] { typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort), typeof(ushort), typeof(SetupOptions), typeof(ushort), typeof(ushort), typeof(double), typeof(double), typeof(ushort) };
     descriptorArray1[0x21] = new XLSDescriptor("SETUP", 0xa1, 0x22, typeof(XLSRecord), objArray1);
     objArray1              = new object[2];
     objArray1[0]           = typeof(ushort);
     objArray2              = new object[] { typeof(SheetIndexes) };
     objArray1[1]           = objArray2;
     descriptorArray1[0x22] = new XLSDescriptor("EXTERNSHEET", 0x17, -1, typeof(ExternsheetRecord), objArray1);
     objArray1              = new object[8];
     objArray1[0]           = "00 00 00";
     objArray1[1]           = typeof(byte);
     objArray1[2]           = typeof(ushort);
     objArray1[3]           = "00 00";
     objArray1[4]           = typeof(ushort);
     objArray1[5]           = "00 00 00 00";
     objArray1[6]           = typeof(ExcelStringWithoutLength);
     objArray2              = new object[] { typeof(byte) };
     objArray1[7]           = objArray2;
     descriptorArray1[0x23] = new XLSDescriptor("NAME", 0x18, -1, typeof(NameRecord), objArray1);
     objArray1              = new object[] { typeof(ushort), "01 04" };
     descriptorArray1[0x24] = new XLSDescriptor("SUPBOOK", 430, 4, typeof(SupBookRecord), objArray1);
     descriptorArray1[0x25] = new XLSDescriptor("EOF", 10, 0, typeof(XLSRecord), null);
     descriptorArray1[0x26] = new XLSDescriptor("WRITEPROT", 0x86, -2, typeof(XLSRecord), null);
     descriptorArray1[0x27] = new XLSDescriptor("WRITEACCESS", 0x5c, -2, typeof(XLSRecord), null);
     descriptorArray1[40]   = new XLSDescriptor("FILESHARING", 0x5b, -2, typeof(XLSRecord), null);
     descriptorArray1[0x29] = new XLSDescriptor("CODEPAGE", 0x42, -2, typeof(XLSRecord), null);
     descriptorArray1[0x2a] = new XLSDescriptor("WINDOWPROTECT", 0x19, -2, typeof(XLSRecord), null);
     descriptorArray1[0x2b] = new XLSDescriptor("OBJECTPROTECT", 0x63, -2, typeof(XLSRecord), null);
     descriptorArray1[0x2c] = new XLSDescriptor("HIDEOBJ", 0x8d, -2, typeof(XLSRecord), null);
     descriptorArray1[0x2d] = new XLSDescriptor("DATEMODE", 0x22, -2, typeof(XLSRecord), null);
     descriptorArray1[0x2e] = new XLSDescriptor("PRECISION", 14, -2, typeof(XLSRecord), null);
     descriptorArray1[0x2f] = new XLSDescriptor("REFRESHALL", 0x1b7, -2, typeof(XLSRecord), null);
     descriptorArray1[0x30] = new XLSDescriptor("BOOKBOOL", 0xda, -2, typeof(XLSRecord), null);
     descriptorArray1[0x31] = new XLSDescriptor("USESELFS", 0x160, -2, typeof(XLSRecord), null);
     descriptorArray1[50]   = new XLSDescriptor("COUNTRY", 140, -2, typeof(XLSRecord), null);
     descriptorArray1[0x33] = new XLSDescriptor("CALCCOUNT", 12, -2, typeof(XLSRecord), null);
     descriptorArray1[0x34] = new XLSDescriptor("CALCMODE", 13, -2, typeof(XLSRecord), null);
     descriptorArray1[0x35] = new XLSDescriptor("REFMODE", 15, -2, typeof(XLSRecord), null);
     descriptorArray1[0x36] = new XLSDescriptor("DELTA", 0x10, -2, typeof(XLSRecord), null);
     descriptorArray1[0x37] = new XLSDescriptor("ITERATION", 0x11, -2, typeof(XLSRecord), null);
     descriptorArray1[0x38] = new XLSDescriptor("SAVERECALC", 0x5f, -2, typeof(XLSRecord), null);
     descriptorArray1[0x39] = new XLSDescriptor("PRINTHEADERS", 0x2a, -2, typeof(XLSRecord), null);
     descriptorArray1[0x3a] = new XLSDescriptor("PRINTGRIDLINES", 0x2b, -2, typeof(XLSRecord), null);
     descriptorArray1[0x3b] = new XLSDescriptor("GRIDSET", 130, -2, typeof(XLSRecord), null);
     descriptorArray1[60]   = new XLSDescriptor("HEADER", 20, -2, typeof(XLSRecord), null);
     descriptorArray1[0x3d] = new XLSDescriptor("FOOTER", 0x15, -2, typeof(XLSRecord), null);
     descriptorArray1[0x3e] = new XLSDescriptor("HCENTER", 0x83, -2, typeof(XLSRecord), null);
     descriptorArray1[0x3f] = new XLSDescriptor("VCENTER", 0x84, -2, typeof(XLSRecord), null);
     descriptorArray1[0x40] = new XLSDescriptor("LEFTMARGIN", 0x26, -2, typeof(XLSRecord), null);
     descriptorArray1[0x41] = new XLSDescriptor("RIGHTMARGIN", 0x27, -2, typeof(XLSRecord), null);
     descriptorArray1[0x42] = new XLSDescriptor("TOPMARGIN", 40, -2, typeof(XLSRecord), null);
     descriptorArray1[0x43] = new XLSDescriptor("BOTTOMMARGIN", 0x29, -2, typeof(XLSRecord), null);
     descriptorArray1[0x44] = new XLSDescriptor("SORT", 0x90, -2, typeof(XLSRecord), null);
     descriptorArray1[0x45] = new XLSDescriptor("PANE", 0x41, -2, typeof(XLSRecord), null);
     descriptorArray1[70]   = new XLSDescriptor("SELECTION", 0x1d, -2, typeof(XLSRecord), null);
     descriptorArray1[0x47] = new XLSDescriptor("STANDARDWIDTH", 0x99, -2, typeof(XLSRecord), null);
     descriptorArray1[0x48] = new XLSDescriptor("LABELRANGES", 0x15f, -2, typeof(XLSRecord), null);
     descriptorArray1[0x49] = new XLSDescriptor("CONDFMT", 0x1b0, -2, typeof(XLSRecord), null);
     descriptorArray1[0x4a] = new XLSDescriptor("CF", 0x1b1, -2, typeof(XLSRecord), null);
     descriptorArray1[0x4b] = new XLSDescriptor("HLINK", 440, -2, typeof(XLSRecord), null);
     descriptorArray1[0x4c] = new XLSDescriptor("QUICKTIP", 0x800, -2, typeof(XLSRecord), null);
     descriptorArray1[0x4d] = new XLSDescriptor("DVAL", 0x1b2, -2, typeof(XLSRecord), null);
     descriptorArray1[0x4e] = new XLSDescriptor("DV", 0x1be, -2, typeof(XLSRecord), null);
     descriptorArray1[0x4f] = new XLSDescriptor("SHEETLAYOUT", 0x862, -2, typeof(XLSRecord), null);
     descriptorArray1[80]   = new XLSDescriptor("SHEETPROTECTION", 0x867, -2, typeof(XLSRecord), null);
     descriptorArray1[0x51] = new XLSDescriptor("RANGEPROTECTION", 0x868, -2, typeof(XLSRecord), null);
     descriptorArray1[0x52] = new XLSDescriptor("SCENPROTECT", 0xdd, -2, typeof(XLSRecord), null);
     descriptorArray1[0x53] = new XLSDescriptor("PASSWORD", 0x13, -2, typeof(XLSRecord), null);
     descriptorArray1[0x54] = new XLSDescriptor("OBJ", 0x5d, -2, typeof(XLSRecord), null);
     descriptorArray1[0x55] = new XLSDescriptor("MSODRAWING", 0xec, -2, typeof(XLSRecord), null);
     descriptorArray1[0x56] = new XLSDescriptor("MSODRAWINGGROUP", 0xeb, -2, typeof(XLSRecord), null);
     descriptorArray1[0x57] = new XLSDescriptor("TXO", 0x1b6, -2, typeof(XLSRecord), null);
     descriptorArray1[0x58] = new XLSDescriptor("SHRFMLA", 0x4bc, -2, typeof(XLSRecord), null);
     objArray1              = new object[] { typeof(ExcelLongString) };
     descriptorArray1[0x59] = new XLSDescriptor("STRING", 0x207, -1, typeof(XLSRecord), objArray1);
     descriptorArray1[90]   = new XLSDescriptor("FILEPASS", 0x2f, -2, typeof(XLSRecord), null);
     descriptorArray1[0x5b] = new XLSDescriptor("MSODRAWINGSELECTION", 0xed, -2, typeof(XLSRecord), null);
     XLSDescriptors.List    = descriptorArray1;
     descriptorArray1       = XLSDescriptors.List;
     for (int num1 = 0; num1 < descriptorArray1.Length; num1++)
     {
         XLSDescriptor descriptor1 = descriptorArray1[num1];
         XLSDescriptors.name2Descriptor.Add(descriptor1.Name, descriptor1);
         XLSDescriptors.code2Descriptor.Add(descriptor1.Code, descriptor1);
     }
 }
Ejemplo n.º 4
0
 // Methods
 public SSTRelated(XLSDescriptor descriptor) : base(descriptor)
 {
 }
Ejemplo n.º 5
0
 public SSTRelated(XLSDescriptor descriptor, int bodySize, BinaryReader br) : base(descriptor, bodySize, br)
 {
 }
Ejemplo n.º 6
0
 // Methods
 protected XLSRecord(XLSDescriptor descriptor)
 {
     this.InitializeDescriptorCode(descriptor);
 }
Ejemplo n.º 7
0
 protected XLSRecord(XLSDescriptor descriptor, int bodySize, BinaryReader br)
 {
     this.recordCode = descriptor.Code;
     this.ReadBody(bodySize, br);
     this.descriptor = descriptor;
 }
Ejemplo n.º 8
0
 private void InitializeDescriptorCode(XLSDescriptor descriptor)
 {
     this.descriptor = descriptor;
     this.recordCode = this.descriptor.Code;
 }