Example #1
0
        private void WriteFXRecord(BinaryWriter writer, FormatInfo info)
        {
            ushort[] clData = new ushort[2];
            clData[0] = BIFF.ExtendedRecord;
            clData[1] = 0x00C;
            WriteUshortArray(writer, clData);

            byte[] clValue = new byte[4];
            clValue[0] = (byte)info.FontIndex;
            clValue[1] = (byte)info.FormatIndex;
            clValue[2] = (byte)0x01;

            byte attr = 0;
            if (info.FontIndex > 0)
                attr |= 0x02;
            if (info.HorizontalAlignment != Alignment.General)
                attr |= 0x04;
            if (info.BackColor.Index != ExcelColor.Automatic.Index)
                attr |= 0x10;
            attr = (byte)(attr << 2);
            clValue[3] = attr;
            WriteByteArray(writer, clValue);

            //(orig & ~mask) | (input & mask)

            ushort horizontalAlignment = (ushort)info.HorizontalAlignment;

            ushort backgroundArea = 1;
            if (info.BackColor.Index != ExcelColor.Automatic.Index)
            {
                backgroundArea = (ushort)((backgroundArea & ~(ushort)0x07C0) | (info.BackColor.Index & (ushort)0x07C0 >> 6) << 6);
                backgroundArea = (ushort)((backgroundArea & ~(ushort)0xF800) | (ExcelColor.WindowText.Index & (ushort)0xF800 >> 11) << 11);
            }
            else
                backgroundArea = 0xCE00;

            ushort[] rest = { horizontalAlignment, backgroundArea, 0x0000, 0x0000 };
            WriteUshortArray(writer, rest);
        }
Example #2
0
        private void BuildInternalTables()
        {
            FormatInfo info;

            foreach (var cell in cells)
            {
                info = new FormatInfo(cell.Value);
                if (cell.Value.Document.FX.IndexOf(info) == -1)
                    cell.Value.Document.FX.Add(info);

                cell.Value.FXIndex = (byte)(cell.Value.Document.FX.IndexOf(info) + 21);
            }
        }