Using Infragistics.Documents.Excel.V16.1 Workbook, where in need to read a cell value based on the column name instead of the index value.
Currently, getting the cell values as below:
row.Cells[2].GetText()l
is there any way i could get in row.Cells["<ColName>"].GetText(), have gone through the documentation , but couldn't find any.
Other thing is get all the cell values of a particular row, i.e, on a worksheetrow object in a single statement , instead of processing it through cell by cell using a loop.
I was able to access the cell value using index already as below,
foreach (WorksheetRow row in sheet.Rows) { bwDate= row.Cells[0].GetText(); bwType= row.Cells[1].GetText(); bwCusip= row.Cells[2].GetText();
............................................................................
}
requirement is to get by column name instead of index, but as you said there is no support for this, woudl liek to recommend this idea for your team, by posting in the link which you have sent
Hello Sowmya,
There does not exist an overload on the WorksheetRow.Cells collection that will allow you to index the value by anything other than the index of the cell at the moment. The best alternative I can recommend in this case is to utilize the GetCell method of the Worksheet object that owns the row/cell. This method accepts a cell address and will return the cell at that address. You will also need the index of the row, which you can get from its “Index” property. You can use code like the following to use this, where “sheet” is the Worksheet:
WorksheetRow row = sheet.Rows[14]; int index = row.Index; var value = sheet.GetCell("B" + index).Value;
As for getting all of the values from the row, there is nothing better than looping through the Cells collection in this case. If you would like to see a method implemented that returns a collection of the cell values or allows you to index the WorksheetRow.Cells collection by column name instead of index, I would recommend suggesting a new product idea for this. You can do this at the WPF Ideas Site, here. This will place you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.
Please let me know if you have any other questions or concerns on this matter.