Welcome to the ASP.NET Core feedback portal. We’re happy you’re here! If you have feedback on how to improve the ASP.NET Core, we’d love to hear it!>
Thanks for joining our community and helping improve Syncfusion products!
Hi,
It would be good if possible to reference cells in a List Object by their column name.
If we import a data table as follows, we can iterate through rows and extract cells based upon their name:
var wbsData = wks.ExportDataTable(wks.UsedRange, ExcelExportDataTableOptions.ColumnNames );foreach (var row in wbsData.Rows)
{
var row1 = row as System.Data.DataRow;
var val = row1["FULL WBS"].ToString();
}
However, the following similar syntax using a list object throws an error.
I have managed to get it to work by first calculating the index of the column I'm interested in and using the Index to reference the value:var tbl = wks.ListObjects.FirstOrDefault(x => x.Name == "WBS_Full");
tbl.ShowHeaderRow = false;
foreach (var row in tbl.Location.Rows)
{
var val = row.["FULL WBS"].Value;
}
var wbsIndex = tbl.Columns.FirstOrDefault(x => x.Name == "FULL WBS").Index;
var val = row.Cells[wbsIndex].Value
It would be good if we could just reference the column by name.