2

How to find Column Position from Header by using text in Spreadsheet Gear?

i.e want to find Remark Text ColumnPosition From SpreadSheet. enter image description here

Jankya
  • 966
  • 2
  • 12
  • 34

2 Answers2

2

Got the result is as below.

SpreadsheetGear.IRange range = workbookView.ActiveWorksheet.Cells.Find("StringtoFind", null, SpreadsheetGear.FindLookIn.Values, SpreadsheetGear.LookAt.Part, SpreadsheetGear.SearchOrder.ByRows, SpreadsheetGear.SearchDirection.Next, true);

Thanks..

Jankya
  • 966
  • 2
  • 12
  • 34
0

You could loop though the columns in the header row until you find your text match.

//Get the cells of a worksheet
SpreadsheetGear.IRange cells = worksheet.Cells;

int iColRemark = 0;
//loop through columns
for (int iCol = 0; iCol < cells.ColumnCount; iCol++)
{
  //check header row for colummn that has the text 'Remark'
  if (cells[0, iCol].Text.Equals("Remark"))
  {
    iColRemark = iCol;
    break;
  }
}
Daniel
  • 5,602
  • 4
  • 33
  • 36