An Excel Table
Inheritance: XmlHelper
コード例 #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;
         }
     }
 }
コード例 #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));
            }
        }
コード例 #3
0
 internal ExcelTableColumn(XmlNamespaceManager ns, XmlNode topNode, ExcelTable tbl, int pos) :
     base(ns, topNode)
 {
     _tbl     = tbl;
     Position = pos;
 }
コード例 #4
0
 internal ExcelTableColumn(XmlNamespaceManager ns, XmlNode topNode, ExcelTable tbl, int pos) :
     base(ns, topNode)
 {
     _tbl = tbl;
     Position = pos;
 }
コード例 #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;
     }
 }
コード例 #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);
        }
コード例 #7
0
ファイル: ExportToExcel.cs プロジェクト: VahidN/PdfReport
        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;
                }
            }
        }