Exemple #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));
        }
Exemple #2
0
        public static byte[] Format(object[] format, object[] args)
        {
            MemoryStream stream1;
            int          num1 = 0;

            using (MemoryStream stream2 = (stream1 = new MemoryStream()))
            {
                using (BinaryWriter writer1 = new BinaryWriter(stream1, new UnicodeEncoding()))
                {
                    XLSDescriptors.FormatHelper(writer1, format, args, ref num1);
                    stream1.Capacity = (int)stream1.Length;
                }
            }
            return(stream1.GetBuffer());
        }
Exemple #3
0
        public static object[] Parse(object[] format, byte[] body, VariableArrayCountDelegate vaCount, StringLengthDelegate lastStringLength)
        {
            if (format == null)
            {
                return(new object[0]);
            }
            object[] objArray1 = new object[format.Length];
            int      num1      = 0;

            using (MemoryStream stream1 = new MemoryStream(body))
            {
                using (BinaryReader reader1 = new BinaryReader(stream1, new UnicodeEncoding()))
                {
                    XLSDescriptors.ParseHelper(reader1, format, ref objArray1, ref num1, vaCount, lastStringLength);
                }
            }
            object[] objArray2 = new object[num1];
            Array.Copy(objArray1, objArray2, num1);
            return(objArray2);
        }
 // Methods
 static VerticalPageBreaksRecord()
 {
     VerticalPageBreaksRecord.staticDescriptor = XLSDescriptors.GetByName("VERTICALPAGEBREAKS");
 }
Exemple #5
0
 private void InitializeDescriptorCode(string name)
 {
     this.InitializeDescriptorCode(XLSDescriptors.GetByName(name));
 }
Exemple #6
0
 public XLSRecord(int recordCode, int bodySize, BinaryReader br)
 {
     this.recordCode = recordCode;
     this.ReadBody(bodySize, br);
     this.descriptor = XLSDescriptors.GetByCode(recordCode);
 }
Exemple #7
0
 // Methods
 static NameRecord()
 {
     NameRecord.staticDescriptor = XLSDescriptors.GetByName("NAME");
 }
Exemple #8
0
 // Methods
 static StyleRecord()
 {
     StyleRecord.staticDescriptor = XLSDescriptors.GetByName("Style");
 }
Exemple #9
0
 // Methods
 static RKRecord()
 {
     RKRecord.staticDescriptor = XLSDescriptors.GetByName("RK");
 }
Exemple #10
0
        public void WriteRecords(AbsXLSRecords destination, string recordName)
        {
            int num1 = XLSDescriptors.GetByName(recordName).Code;

            this.WriteRecords(destination, num1);
        }
Exemple #11
0
        private static void FormatHelper(BinaryWriter bw, object[] format, object[] args, ref int currentArgIndex)
        {
            object[] objArray2 = format;
            for (int num2 = 0; num2 < objArray2.Length; num2++)
            {
                object obj1 = objArray2[num2];
                if (obj1 is string)
                {
                    bw.Write(Utilities.HexStr2ByteArr((string)obj1));
                }
                else if (obj1 is Type)
                {
                    object obj2  = args[currentArgIndex];
                    Type   type1 = (Type)obj1;
                    if (type1.IsEnum)
                    {
                        type1 = Enum.GetUnderlyingType(type1);
                    }
                    switch (type1.FullName)
                    {
                    case "System.Int16":
                    {
                        bw.Write((short)obj2);
                        break;
                    }

                    case "System.UInt16":
                    {
                        bw.Write((ushort)obj2);
                        break;
                    }

                    case "System.UInt32":
                    {
                        bw.Write(UInt32.Parse(obj2.ToString()));
                        break;
                    }

                    case "System.UInt64":
                    {
                        bw.Write((ulong)obj2);
                        break;
                    }

                    case "System.Byte":
                    {
                        bw.Write((byte)obj2);
                        break;
                    }

                    case "System.Char":
                    {
                        bw.Write((char)obj2);
                        break;
                    }

                    case "System.Single":
                    {
                        bw.Write((float)obj2);
                        break;
                    }

                    case "System.Double":
                    {
                        bw.Write((double)obj2);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelShortString":
                    {
                        ((ExcelShortString)obj2).Write(bw);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelLongString":
                    {
                        ((ExcelLongString)obj2).Write(bw);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelStringWithoutLength":
                    {
                        ((ExcelStringWithoutLength)obj2).Write(bw);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelLongStrings":
                    {
                        ((ExcelLongStrings)obj2).Write(bw);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.CellRecordHeader":
                    {
                        ((CellRecordHeader)obj2).Write(bw);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.SheetIndexes":
                    {
                        ((SheetIndexes)obj2).Write(bw);
                        break;
                    }

                    default:
                    {
                        throw new Exception("Internal error: unsupported type in format.");
                    }
                    }
                    currentArgIndex += 1;
                }
                else
                {
                    if (!(obj1 is object[]))
                    {
                        throw new Exception("Internal error: wrong format in descriptor.");
                    }
                    object[] objArray1 = args[currentArgIndex] as object[];
                    int      num1      = 0;
                    while (num1 < objArray1.Length)
                    {
                        XLSDescriptors.FormatHelper(bw, (object[])obj1, objArray1, ref num1);
                    }
                    currentArgIndex += 1;
                }
            }
        }
Exemple #12
0
        public static void ParseHelper(BinaryReader br, object[] format, ref object[] loadedArgs, ref int currentArgIndex, VariableArrayCountDelegate vaCount, StringLengthDelegate lastStringLength)
        {
            object[] objArray4 = format;
            for (int num5 = 0; num5 < objArray4.Length; num5++)
            {
                object obj1 = objArray4[num5];
                if (obj1 is string)
                {
                    Stream stream1 = br.BaseStream;
                    stream1.Position += Utilities.GetByteArrLengthFromHexStr((string)obj1);
                }
                else if (obj1 is Type)
                {
                    Type type1 = (Type)obj1;
                    if (type1.IsEnum)
                    {
                        type1 = Enum.GetUnderlyingType(type1);
                    }
                    switch (type1.FullName)
                    {
                    case "System.Int16":
                    {
                        loadedArgs[currentArgIndex] = br.ReadInt16();
                        break;
                    }

                    case "System.UInt16":
                    {
                        loadedArgs[currentArgIndex] = br.ReadUInt16();
                        break;
                    }

                    case "System.UInt32":
                    {
                        loadedArgs[currentArgIndex] = br.ReadUInt32();
                        break;
                    }

                    case "System.UInt64":
                    {
                        loadedArgs[currentArgIndex] = br.ReadUInt64();
                        break;
                    }

                    case "System.Byte":
                    {
                        loadedArgs[currentArgIndex] = br.ReadByte();
                        break;
                    }

                    case "System.Char":
                    {
                        loadedArgs[currentArgIndex] = br.ReadChar();
                        break;
                    }

                    case "System.Single":
                    {
                        loadedArgs[currentArgIndex] = br.ReadSingle();
                        break;
                    }

                    case "System.Double":
                    {
                        loadedArgs[currentArgIndex] = br.ReadDouble();
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelShortString":
                    {
                        loadedArgs[currentArgIndex] = new ExcelShortString(br);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelLongString":
                    {
                        loadedArgs[currentArgIndex] = new ExcelLongString(br);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelStringWithoutLength":
                    {
                        loadedArgs[currentArgIndex] = new ExcelStringWithoutLength(br, lastStringLength(loadedArgs));
                        break;
                    }

                    case "MB.WinEIDrive.Excel.ExcelLongStrings":
                    {
                        int num1 = vaCount(loadedArgs, null, (int)br.BaseStream.Length);
                        loadedArgs[currentArgIndex] = new ExcelLongStrings(br, num1, 0);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.CellRecordHeader":
                    {
                        loadedArgs[currentArgIndex] = new CellRecordHeader(br);
                        break;
                    }

                    case "MB.WinEIDrive.Excel.SheetIndexes":
                    {
                        loadedArgs[currentArgIndex] = new SheetIndexes(br);
                        break;
                    }

                    default:
                    {
                        throw new Exception("Internal error: unsupported type in format.");
                    }
                    }
                    currentArgIndex += 1;
                }
                else
                {
                    if (!(obj1 is object[]))
                    {
                        throw new Exception("Internal error: wrong format in descriptor.");
                    }
                    object[] objArray1 = (object[])obj1;
                    int      num2      = vaCount(loadedArgs, objArray1, (int)br.BaseStream.Length);
                    object[] objArray2 = new object[objArray1.Length * num2];
                    int      num3      = 0;
                    for (int num4 = 0; num4 < num2; num4++)
                    {
                        XLSDescriptors.ParseHelper(br, objArray1, ref objArray2, ref num3, vaCount, lastStringLength);
                    }
                    object[] objArray3 = new object[num3];
                    Array.Copy(objArray2, objArray3, num3);
                    loadedArgs[currentArgIndex] = objArray3;
                    currentArgIndex            += 1;
                }
            }
        }
 // Methods
 static ExternsheetRecord()
 {
     ExternsheetRecord.staticDescriptor = XLSDescriptors.GetByName("EXTERNSHEET");
 }
Exemple #14
0
 // Methods
 static DBCellRecord()
 {
     DBCellRecord.staticDescriptor = XLSDescriptors.GetByName("DBCell");
 }
Exemple #15
0
 // Methods
 static IndexRecord()
 {
     IndexRecord.staticDescriptor = XLSDescriptors.GetByName("Index");
 }
Exemple #16
0
 protected void InitializeBody(object[] args)
 {
     this.InitializeBody(XLSDescriptors.Format(this.descriptor.BodyFormat, args));
 }
Exemple #17
0
 public object[] GetArguments()
 {
     return(XLSDescriptors.Parse(this.descriptor.BodyFormat, this.body, new XLSDescriptors.VariableArrayCountDelegate(this.GetVariableArraySize), new XLSDescriptors.StringLengthDelegate(this.GetStringLength)));
 }
Exemple #18
0
 // Methods
 static FormulaRecord()
 {
     FormulaRecord.staticDescriptor = XLSDescriptors.GetByName("Formula");
 }
 // Methods
 static HorizontalPageBreaksRecord()
 {
     HorizontalPageBreaksRecord.staticDescriptor = XLSDescriptors.GetByName("HORIZONTALPAGEBREAKS");
 }
 // Methods
 static PaletteRecord()
 {
     PaletteRecord.staticDescriptor = XLSDescriptors.GetByName("Palette");
 }
Exemple #21
0
 // Methods
 static ExtSSTRecord()
 {
     ExtSSTRecord.staticDescriptor = XLSDescriptors.GetByName("ExtSST");
 }
Exemple #22
0
        public void CopyRecords(PreservedRecords source, string recordName)
        {
            int num1 = XLSDescriptors.GetByName(recordName).Code;

            this.CopyRecords(source, num1);
        }
 // Methods
 static MulBlankRecord()
 {
     MulBlankRecord.staticDescriptor = XLSDescriptors.GetByName("MulBlank");
 }
Exemple #24
0
 // Methods
 static SupBookRecord()
 {
     SupBookRecord.staticDescriptor = XLSDescriptors.GetByName("SUPBOOK");
 }
Exemple #25
0
 // Methods
 static BoundSheetRecord()
 {
     BoundSheetRecord.staticDescriptor = XLSDescriptors.GetByName("BoundSheet");
 }
Exemple #26
0
 // Methods
 static SSTRecord()
 {
     SSTRecord.staticDescriptor = XLSDescriptors.GetByName("SST");
 }
Exemple #27
0
 // Methods
 static MulRKRecord()
 {
     MulRKRecord.staticDescriptor = XLSDescriptors.GetByName("MulRK");
 }
Exemple #28
0
 // Methods
 static MergedCellsRecord()
 {
     MergedCellsRecord.staticDescriptor = XLSDescriptors.GetByName("MergedCells");
 }
 // Methods
 static ContinueRecord()
 {
     ContinueRecord.staticDescriptor = XLSDescriptors.GetByName("Continue");
 }