Ejemplo n.º 1
0
        ExcelTableTemplate ParseTable(ToxyCell cell)
        {
            if (cell == null || string.IsNullOrEmpty(cell.Value))
            {
                return(null);
            }
            var expr = cell.Value;

            if (string.IsNullOrEmpty(expr))
            {
                return(null);
            }
            var eachpart = REG_EXPR_BEGINEACH.Match(expr).Groups;

            if (eachpart.Count == 0)
            {
                return(null);
            }

            ExcelTableTemplate token = new ExcelTableTemplate()
            {
                RowIndex = _currRowIndex, ColIndex = _currColIndex, BindName = eachpart[0].Value
            };


            if (eachpart.Count == 1)
            {
                token.ValueName = eachpart[0].Value;
                var valGroup = REG_EXPR_Value.Match(expr).Groups;
                if (valGroup.Count == 0)
                {
                    token.Cells.Add(new ExcelCellTemplate()
                    {
                        RowIndex = _currRowIndex, ColIndex = _currColIndex
                    });
                    _currColIndex++;
                }
                else
                {
                    var row = _currTable.Rows[_currRowIndex];
                    for (; _currColIndex < row.Cells.Count; _currColIndex++)
                    {
                        var celltoken = ParseCell(row.Cells[_currColIndex]);
                        if (celltoken != null)
                        {
                            token.Cells.Add(celltoken);
                        }
                    }
                }
            }
            return(token);
        }
Ejemplo n.º 2
0
        ExcelTableTemplate ParseTable(ToxyCell cell)
        {
            if (cell == null || string.IsNullOrEmpty(cell.Value))
            {
                return null;
            }
            var expr = cell.Value;
            if (string.IsNullOrEmpty(expr))
                return null;
            var eachpart = REG_EXPR_BEGINEACH.Match(expr).Groups;
            if (eachpart.Count == 0) return null;

            ExcelTableTemplate token = new ExcelTableTemplate() { RowIndex = _currRowIndex, ColIndex = _currColIndex, BindName = eachpart[0].Value };

            if (eachpart.Count == 1)
            {
                token.ValueName = eachpart[0].Value;
                var valGroup = REG_EXPR_Value.Match(expr).Groups;
                if (valGroup.Count == 0)
                {
                    token.Cells.Add(new ExcelCellTemplate() { RowIndex = _currRowIndex, ColIndex = _currColIndex });
                    _currColIndex++;
                }
                else
                {
                    var row = _currTable.Rows[_currRowIndex];
                    for (; _currColIndex < row.Cells.Count; _currColIndex++)
                    {
                        var celltoken = ParseCell(row.Cells[_currColIndex]);
                        if (celltoken != null)
                            token.Cells.Add(celltoken);
                    }
                }
            }
            return token;
        }