Hi
I want to get the current range of excel and want to clear all cells with updated data.
I'm using below code while using Microsoft.Office.Interop.Excel
Excel.Range xlRange = xlWorksheet.Range["A1"].CurrentRegion;
Can you help me in this case.
Workbook workbook = new Workbook();
workbook.LoadFromFile(@"E:\sample.xlsx");
Worksheet sheet = workbook.Worksheets[0];
//get all ranges in the worksheet
CellRange cr = sheet.AllocatedRange;
//clear all objects
cr.ClearAll();
workbook.SaveToFile("result.xlsx", FileFormat.Version2010);
sheet.Range["A1"].CurrentRegion;