Esempio n. 1
0
        /// <summary>
        /// 添加汇总列
        /// </summary>
        /// <param name="columns">表示行的字符:包括字段名、行索引(0~255)、Excel列字母</param>
        public void AddSumColumns(IEnumerable <string> columns)
        {
            int                 colIndex;
            IList <string>      fields       = new List <string>();
            IList <int>         colIndexes   = new List <int>();
            IEnumerable <Field> tmpFieldList = null;

            foreach (var column in columns)
            {
                tmpFieldList = _fields.Where(p => p.Name == column);
                if (tmpFieldList.Count() > 0)
                {
                    colIndexes.Add(tmpFieldList.First().ColIndex);
                }
                else if (int.TryParse(column, out colIndex))
                {
                    colIndexes.Add(colIndex);
                }
                else if (ParseUtil.IsAlphabets(column, true))
                {
                    colIndex = ParseUtil.FromBase26(column);
                    if (colIndex > 0 && colIndex < LIMITED_COLUMN_COUNT)
                    {
                        colIndexes.Add(colIndex - 1);
                    }
                }
            }
            AddSumColumns(colIndexes);
        }