public SourceTable GetSourceTable(HtmlExtractorBase htmlExtractor) { Boolean AddHeaderRow = false; Boolean AddContextColumn = false; Int32 Height = Rows.Count; if (ColumnContextTakes.Cells.items.Any()) { Height++; AddHeaderRow = true; } Int32 Width = 0; if (Rows.Any()) { Width = Rows.Max(x => x.Cells.Count); } if (Rows.All(x => x.RowContextTake != null)) { Width++; AddContextColumn = true; } SourceTable output = new SourceTable(Width, Height); Int32 ri = 0; if (AddHeaderRow) { for (int i = 0; i < ColumnContextTakes.Cells.Count; i++) { //Int32 rx = i; RecordTemplateItemTake take = (RecordTemplateItemTake)ColumnContextTakes.Cells.items[i]; //String takeSubPath = ItemDescriptors.ValueCellSubXPath[i]; //Int32 rx = ItemDescriptors.CellIndex(takeSubPath, AddContextColumn); Int32 rx = ItemDescriptors.CellIndex(take, AddContextColumn); if (rx > -1) { htmlExtractor.SetSourceTableCell(output[rx, ri], take.SelectedNode, null); } //if (AddContextColumn) //{ // rx++; //} } ri++; } foreach (var row in Rows) { if (AddContextColumn) { if (row.RowContextTake != null) { htmlExtractor.SetSourceTableCell(output[0, ri], row.RowContextTake.SelectedNode, null); } } foreach (var take in row.Cells.items) { Int32 rx = ItemDescriptors.CellIndex(take, AddContextColumn); if (rx < output.Width) { htmlExtractor.SetSourceTableCell(output[rx, ri], take.SelectedNode, null); } } ri++; } output = output.GetDistinctRows(); return(output); }