Free Support Forum -

Get column number based on string in the first row of the column

After I import my datatable into a worksheet, I would like to be able to get the the column index based on the string that is in the first row of the column. What is the best way to do this?


Please find attached the sample code for your requirement, you may adjust it accordingly.

Sample code:

Workbook workbook = new Workbook();
Worksheet worksheet = workbook.Worksheets[0];

//Your code regarding Importing DataTable goes here.


string mystring = “Your string goes here”;
Aspose.Cells.Cell fcell = worksheet.Cells.FindString(mystring, null);
Column col = fcell.Column;

Thank you.