public static SourceTable GetDistinctRows(this SourceTable source) { var all = source.GetContentCells(false); all = TakeDistinct(all); if (!all.Any()) { return(null); } Int32 Width = all.Max(x => x.Count); Int32 Height = all.Count; var output = new SourceTable(Width, Height); for (int i = 0; i < output.Height; i++) { var row = all[i]; for (int j = 0; j < output.Width; j++) { if (j < row.Count()) { output.SetCell(j, i, row[j]); // output[j, i].Value = row[j]; } } } return(output); }
public static SourceTable Merge(this IEnumerable <List <List <SourceTableCell> > > contentSets, Boolean asColumns, Boolean OnlyDistinct) { var all = new List <List <SourceTableCell> >(); foreach (var cset in contentSets) { all.AddRange(cset); } if (OnlyDistinct) { all = TakeDistinct(all); } if (!all.Any()) { return(null); } Int32 Width = all.Max(x => x.Count); SourceTable output = null; if (asColumns) { output = new SourceTable(all.Count, Width); for (int i = 0; i < output.Width; i++) { var column = all[i]; for (int j = 0; j < output.Height; j++) { if (j < column.Count) { output.SetCell(i, j, column[j]); //output[i, j].Value = column[j]; } } } } else { output = new SourceTable(Width, all.Count); for (int i = 0; i < output.Height; i++) { var row = all[i]; for (int j = 0; j < output.Width; j++) { if (j < row.Count()) { output.SetCell(i, j, row[j]); // output[j, i].Value = row[j]; } } } } return(output); }