An Excel Table
Inheritance: XmlHelper
Ejemplo n.º 1
0
 internal ExcelTableColumnCollection(ExcelTable table)
 {
     Table = table;
     foreach (XmlNode node in table.TableXml.SelectNodes("//d:table/d:tableColumns/d:tableColumn", table.NameSpaceManager))
     {
         var item = new ExcelTableColumn(table.NameSpaceManager, node, table, _cols.Count);
         _cols.Add(item);
         _colNames.Add(_cols[_cols.Count - 1].Name, _cols.Count - 1);
         var id = item.Id;
         if (id >= _maxId)
         {
             _maxId = id + 1;
         }
     }
 }
Ejemplo n.º 2
0
        public static IEnumerable <IDictionary <string, object> > GetRows(this ExcelTable table)
        {
            var addr     = table.Address;
            var cells    = table.WorkSheet.Cells;
            var firstCol = addr.Start.Column;
            var firstRow = addr.Start.Row;

            if (table.ShowHeader)
            {
                firstRow++;
            }
            var lastRow = addr.End.Row;

            for (int r = firstRow; r <= lastRow; r++)
            {
                yield return(Enumerable.Range(0, table.Columns.Count).ToDictionary(x => table.Columns[x].Name, x => cells[r, firstCol + x].Value));
            }
        }
Ejemplo n.º 3
0
 internal ExcelTableColumn(XmlNamespaceManager ns, XmlNode topNode, ExcelTable tbl, int pos) :
     base(ns, topNode)
 {
     _tbl     = tbl;
     Position = pos;
 }
Ejemplo n.º 4
0
 internal ExcelTableColumn(XmlNamespaceManager ns, XmlNode topNode, ExcelTable tbl, int pos) :
     base(ns, topNode)
 {
     _tbl = tbl;
     Position = pos;
 }
Ejemplo n.º 5
0
 private IEnumerable<int> YieldTableRowNums(ExcelTable table)
 {
     for (int rowNum = table.Address.Start.Row + 1; rowNum <= table.Address.End.Row; rowNum++)
     {
         yield return rowNum;
     }
 }
Ejemplo n.º 6
0
        private void ProcessTableRow(ExcelWorksheet worksheet, ExcelTable table, int rowNum)
        {
            var output = new PSObject();

            foreach (var col in table.Columns)
            {

                var val = worksheet.GetValue(rowNum, 1 + col.Position);
                var prop = new PSNoteProperty(col.Name, val);

                output.Members.Add(prop);

            }

            this.WriteObject(output);
        }
Ejemplo n.º 7
0
        private void setAggregateFunctions(ExcelTable tbl)
        {
            var idx = 0;
            foreach (var item in _columns)
            {
                idx++;
                if (item.AggregateFunction == null) continue;

                var function = item.AggregateFunction;
                var aggregateFunction = item.AggregateFunction as AggregateProvider;
                if (aggregateFunction != null)
                {
                    function = aggregateFunction.ColumnAggregateFunction;
                }

                var type = function.GetType();
                RowFunctions rowFunction;
                if (_rowFunctions.TryGetValue(type, out rowFunction))
                {
                    if (!tbl.ShowTotal) tbl.ShowTotal = true;
                    tbl.Columns[_uniqueHeaders[idx]].DataCellStyleName = "TableNumber";
                    tbl.Columns[_uniqueHeaders[idx]].TotalsRowFunction = rowFunction;
                    _worksheet.Cells[_row, idx].Style.Numberformat.Format = Numberformat;
                }
            }
        }