Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

Can you advice how to clear the content of the cell (B2:E4) in excel sheet using c#.
Posted

Use following solution to clear content for specific range.

Microsoft.Office.Interop.Excel.Application excel = new Microsoft.Office.Interop.Excel.Application();
           Microsoft.Office.Interop.Excel.Workbook excelWorkbook = excel.Workbooks.Open(@"D:\Book1.xls");
           Microsoft.Office.Interop.Excel._Worksheet excelWorkbookWorksheet = excelWorkbook.Sheets[1];
           var rng = excelWorkbookWorksheet.get_Range("B2:E4", Type.Missing);
           rng.Cells.Clear();
           excelWorkbook.Save();
 
Share this answer
 
Comments
abhicoolhot 3-Jul-14 15:03pm    
I tried above code.. But am getting error message "no overload for method open takes 1 argument".

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900