2
如何使用Spreadsheet Gear中的文本從標題中找到列位置?如何在SpreadsheetGear中通過文本查找ColumnPostion?
即要從SpreadSheet中找到備註文本ColumnPosition。
如何使用Spreadsheet Gear中的文本從標題中找到列位置?如何在SpreadsheetGear中通過文本查找ColumnPostion?
即要從SpreadSheet中找到備註文本ColumnPosition。
您可以通過標題行中的列循環,直到找到文本匹配。
//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;
}
}
得到的結果如下。
SpreadsheetGear.IRange range = workbookView.ActiveWorksheet.Cells.Find("StringtoFind", null, SpreadsheetGear.FindLookIn.Values, SpreadsheetGear.LookAt.Part, SpreadsheetGear.SearchOrder.ByRows, SpreadsheetGear.SearchDirection.Next, true);
謝謝..
有趣的問題先生 –