Example #1
0
        private Bytes MERGEDCELLS()
        {
            Bytes mergedcells = new Bytes();

            int areaIndex = 0;
            int mergeAreaCount = _mergeAreas.Count;
            long areasPerRecord = 1027;
            int recordsRequired = (int)Math.Ceiling(_mergeAreas.Count/(double)areasPerRecord);
            for (int recordIndex = 0; recordIndex < recordsRequired; recordIndex++)
            {
                ushort blockAreaIndex = 0;
                Bytes rangeAddresses = new Bytes();
                while (areaIndex < mergeAreaCount && blockAreaIndex < areasPerRecord)
                {
                    rangeAddresses.Append(CellRangeAddress(_mergeAreas[areaIndex]));

                    blockAreaIndex++;
                    areaIndex++;
                }
                rangeAddresses.Prepend(BitConverter.GetBytes(blockAreaIndex));
                mergedcells.Append(Record.GetBytes(RID.MERGEDCELLS, rangeAddresses));
            }

            return mergedcells;
        }
Example #2
0
        private static Bytes BOUNDSHEET(Worksheet sheet, int basePosition)
        {
            Bytes bytes = new Bytes();

            Bytes sheetName = XlsDocument.GetUnicodeString(sheet.Name, 8);
            bytes.Append(WorksheetVisibility.GetBytes(sheet.Visibility));
            bytes.Append(WorksheetType.GetBytes(sheet.SheetType));
            bytes.Append(sheetName);
            bytes.Prepend(BitConverter.GetBytes((int) basePosition)); //TODO: this should probably be unsigned 32 instead

            bytes.Prepend(BitConverter.GetBytes((ushort) bytes.Length));
            bytes.Prepend(RID.BOUNDSHEET);

            return bytes;
        }