Find and replace text in Excel using C# -
i find , replace group of text in excel using c#, want replace happen text in first row only.
i have used google , found few paid resource aspose api,spire.xls,etc, looking open source resource or other efficient way achieve this. please suggest.
try this:
public static void replacetextinexcelfile(string filename, string replace, string replacement) { object m = type.missing; // open excel. application app = new applicationclass(); // open workbook. workbook wb = app.workbooks.open( filename, m, false, m, m, m, m, m, m, m, m, m, m, m, m); // active worksheet. (replace if need to.) worksheet ws = (worksheet)wb.activesheet; // used range. range r = (range)ws.usedrange; // call replace method replace instances. bool success = (bool)r.replace( replace, replacement, xllookat.xlwhole, xlsearchorder.xlbyrows, true, m, m, m); // save , close. wb.save(); app.quit(); app = null; }
Comments
Post a Comment