Пример #1
0
        private static void ParseSubTitle(Worksheet sheet, int rowIndex, Title title)
        {
            Range row = sheet.Rows[rowIndex];

            for (int i = title.FromIndex; i <= title.ToIndex; i++)
            {
                Range  subTitleRange = row.Cells[1, i + 1];
                string subTitleValue = subTitleRange.Value?.ToString();
                if (string.IsNullOrWhiteSpace(subTitleValue))
                {
                    continue;
                }

                var(subTitleName, tags) = SheetLoadUtil.ParseNameAndMetaAttrs(subTitleValue);


                var newSubTitle = new Title()
                {
                    Name      = subTitleName,
                    FromIndex = i,
                    Tags      = tags,
                };

                if (subTitleRange.MergeCells)
                {
                    newSubTitle.ToIndex = i + subTitleRange.MergeArea.Count - 1;
                }
                else
                {
                    newSubTitle.ToIndex = i;
                }
                title.AddSubTitle(newSubTitle);
            }
            if (rowIndex < sheet.UsedRange.Rows.Count && TryParseNextSubFieldRowIndex(sheet.Cells, rowIndex + 1, out int nextRowIndex))
            {
                foreach (var subTitle in title.SubTitleList)
                {
                    ParseSubTitle(sheet, nextRowIndex, subTitle);
                }
            }
        }