Пример #1
0
        void ParseTable(ICell cell, string template, ExcelSheetMetaData sheetMeta)
        {
            var        tokens        = template.Split(',');
            ExcelTable tableTemplate = new ExcelTable()
            {
                RowIndex = cell.RowIndex,
                ColIndex = cell.ColumnIndex,
            };


            foreach (var token in tokens)
            {
                var pair = token.Split(':');

                switch (pair[0].ToLower())
                {
                case "each":
                    tableTemplate.Each = pair[1];
                    break;

                case "direction":
                    tableTemplate.Direction = pair[1];
                    break;

                case "treecode":
                    tableTemplate.TreeCode = pair[1];
                    break;
                }
            }

            var row = cell.Row;

            for (int i = cell.ColumnIndex; i < row.LastCellNum; i++)
            {
                ParseCell(row.Cells[i], tableTemplate.Cells);
            }
            if (tableTemplate.Cells.FirstOrDefault(o => o.IsHide || o.IsLock) != null)
            {
                cell.Sheet.ProtectSheet(PROTECT_PASSWROD);
            }

            sheetMeta.TableTemplates.Add(tableTemplate);
        }
Пример #2
0
        void ParseTable(ICell cell, string template, ExcelSheetMetaData sheetMeta)
        {
            var tokens = template.Split(',');
            ExcelTable tableTemplate = new ExcelTable()
            {
                RowIndex = cell.RowIndex,
                ColIndex = cell.ColumnIndex,

            };

            foreach (var token in tokens)
            {
                var pair = token.Split(':');

                switch (pair[0].ToLower())
                {
                    case "each":
                        tableTemplate.Each = pair[1];
                        break;
                    case "direction":
                        tableTemplate.Direction = pair[1];
                        break;
                    case "treecode":
                        tableTemplate.TreeCode = pair[1];
                        break;
                }

            }

            var row = cell.Row;
            for (int i = cell.ColumnIndex; i < row.LastCellNum; i++)
            {
                ParseCell(row.Cells[i], tableTemplate.Cells);
            }
            if (tableTemplate.Cells.FirstOrDefault(o => o.IsHide || o.IsLock) != null)
            {
                cell.Sheet.ProtectSheet(PROTECT_PASSWROD);
            }

            sheetMeta.TableTemplates.Add(tableTemplate);
        }