Esempio n. 1
0
 public void LittleEndian0xFE()
 {
     byte b = 0xFE;
     Bytes bytes = new Bytes();
     bytes.Append(b);
     bool[] bits = bytes.GetBits().Values;
     Assert.AreEqual(8, bits.Length, "Bits length");
     Assert.IsFalse(bits[0], "Bit 0 value");
     for (int i = 1; i < 8; i++)
         Assert.IsTrue(bits[i], string.Format("Bit {0} value", i));
 }
Esempio n. 2
0
 public void LittleEndian0x0101()
 {
     byte[] bs = new byte[] { 0x01, 0x01 };
     Bytes bytes = new Bytes();
     bytes.Append(bs);
     bool[] bits = bytes.GetBits().Values;
     Assert.AreEqual(16, bits.Length, "Bits length");
     Assert.IsTrue(bits[0], "Bit 0 value");
     Assert.IsTrue(bits[8], "Bit 8 value");
     for (int i = 1; i < 8; i++)
         Assert.IsFalse(bits[i], string.Format("Bit {0} value", i));
     for (int i = 9; i < 16; i++)
         Assert.IsFalse(bits[i], string.Format("Bit {0} value", i));
 }
Esempio n. 3
0
        private Bytes COLINFO_OPTION_FLAGS()
        {
            bool[] bits = new bool[16];
            bits[0] = _hidden;
            Bytes outlineBytes = new Bytes(_outlineLevel);
            bool[] outlineLevelBits = outlineBytes.GetBits().Get(3).Values;
            outlineLevelBits.CopyTo(bits, 8);
            bits[12] = _collapsed;

            return new Bytes.Bits(bits).GetBytes();
        }
Esempio n. 4
0
        private void ReadXF_3(Bytes bytes)
        {
            Bytes.Bits bits = bytes.GetBits();

            ushort parentStyleXfIndex = bits.Get(4, 12).ToUInt16();
            if (parentStyleXfIndex == 4095)
            {
                //this is a Style XF -- do nothing
            }
            else
            {
                ReadStyleXfIndex = parentStyleXfIndex; //we'll assign the style xf index later using the xfIdxLookups collected by Workbook.ReadBytes()
            }

            ReadXF_TYPE_PROT(bits.Get(4));
        }
Esempio n. 5
0
 private void DecodeRK(Bytes bytes)
 {
     Bytes.Bits bits = bytes.GetBits();
     bool div100 = bits.Values[0];
     bool isInt = bits.Values[1];
     if (isInt)
     {
         Value = DecodeRKInt(bits, div100);
         _type = (Value is Int32) ? CellTypes.Integer : CellTypes.Float;
     }
     else
     {
         Value = DecodeRKFloat(bits, div100);
         _type = CellTypes.Float;
     }
 }
Esempio n. 6
0
        private static Bytes RKDecimalValue(object val, bool div100)
        {
            double rk = Convert.ToDouble(val);

            if (div100)
            {
                rk *= 10; //doing a single (tmp *= 100) operation introduces float inaccuracies (1.1 * 10 * 10 = 110.0, whereas 1.1 * 100 = 110.000000000001)
                rk *= 10;
            }

            Bytes bytes = new Bytes(BitConverter.GetBytes(rk));
            List<bool> bitList = new List<bool>();
            bitList.Add(div100);
            bitList.Add(false);
            bitList.AddRange(bytes.GetBits().Get(34, 30).Values);

            return (new Bytes.Bits(bitList.ToArray())).GetBytes();
        }