示例#1
0
 private Spreadsheet(Dictionary <int, ISpreadsheetRow> rows, ISpreadsheetHeader spreadsheetHeader)
 {
     ColumnCount        = spreadsheetHeader.ColumnCount;
     RowCount           = rows.Keys.Max() + 1;
     _spreadsheetHeader = spreadsheetHeader;
     _emptyRow          = new SpreadsheetRow(_spreadsheetHeader, Enumerable.Empty <KeyValuePair <int, string> >());
     _rowsByIndex       = rows;
 }
示例#2
0
        public Spreadsheet(IEnumerable <Cell> cells, IEnumerable <KeyValuePair <int, string> > columnHeaders = null)
        {
            columnHeaders = columnHeaders ?? Enumerable.Empty <KeyValuePair <int, string> >();

            //TODO: improve performance here
            RowCount    = cells.Max(x => x.Row) + 1;
            ColumnCount = cells.Select(x => x.Column).Union(columnHeaders.Select(x => x.Key)).Max() + 1;

            _spreadsheetHeader = new SpreadsheetHeader(ColumnCount, columnHeaders);

            _emptyRow    = new SpreadsheetRow(_spreadsheetHeader, Enumerable.Empty <KeyValuePair <int, string> >());
            _rowsByIndex = cells.GroupBy(x => x.Row)
                           .ToDictionary(
                x => x.Key,
                x => (ISpreadsheetRow) new SpreadsheetRow(_spreadsheetHeader, x.Select(y => new KeyValuePair <int, string>(y.Column, y.Value))));
        }
示例#3
0
 private SpreadsheetRow(ISpreadsheetHeader spreadsheetHeader, Dictionary <int, string> valuesColumnIndex)
 {
     ColumnCount        = spreadsheetHeader.ColumnCount;
     _byColumnIndex     = valuesColumnIndex;
     _spreadsheetHeader = spreadsheetHeader;
 }
示例#4
0
 public ISpreadsheetRow CloneWithOtherHeader(ISpreadsheetHeader spreadsheetHeader)
 {
     return(new SpreadsheetRow(spreadsheetHeader, _byColumnIndex));
 }
示例#5
0
 public SpreadsheetRow(ISpreadsheetHeader spreadsheetHeader, IEnumerable <KeyValuePair <int, string> > cells)
     : this(spreadsheetHeader, cells.ToDictionary(x => x.Key, x => x.Value))
 {
 }