How to Select all the cells in a worksheet in Excel.Range object of c#?

Chethan picture Chethan · Jan 31, 2011 · Viewed 67.5k times · Source

I am trying to select all the cells in an Excel sheet in the Excel.Range object of C# for applying auto fit, border etc. I have some merged cells within the sheets.

Is there any simple trick to do so?

Answer

jocelyn picture jocelyn · Nov 8, 2011
public void refreshSheetColumsSize(Worksheet ws)
 {
    ws.get_Range("a1").EntireRow.EntireColumn.Select();         
 }