c# - How to get specific Range in Excel through COM Interop? -
i have following problem. have read excel file through com interop. new programming com interop.
i search specific string using this:
this.sheet = (excel.worksheet)this.excelapp.workbook.sheets.item[this.sheetname]; this.sheet.activate(); excel.range firstrow = this.sheet.range["a1", "xfd1"]; excel.range foundrange = firstrow.find( this.stringisearch, type.missing, type.missing, excel.xllookat.xlwhole, excel.xlsearchorder.xlbycolumns, excel.xlsearchdirection.xlnext, false, false, type.missing);
no want use foundrange starting point range.
something this
excel.range myrange = this.sheet.range[foundrange + 2 rows, + 1 column & lastrow];
i don't see way this. there one?
okay, after sleep have found answer.
int startcolumn = header.cells.column; int startrow = header.cells.row + 1; excel.range startcell = this.sheet.cells[startrow, startcolumn]; int endcolumn = startcolumn + 1; int endrow = 65536; excel.range endcell = this.sheet.cells[endrow, endcolumn]; excel.range myrange = this.sheet.range[startcell, endcell];
Comments
Post a Comment