如何选择整个excel表在C#Excel.Range对象?如何选择、对象、Excel、excel

2023-09-04 00:39:18 作者:怀念原属于我的温柔ゝ

我想选择整个Excel工作表中的CC#的 Excel.Range 对象将自动调整,边框等我有表内的一些合并单元格

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

有没有什么简单的一招这样做呢?

Is there any simple trick to do so?

推荐答案

从此处拍摄,这将选择所有单元格在工作表中:

Taken from here, this will select all cells in the worksheet:

lastCol = ActiveSheet.Range("a1").End(xlToRight).Column
lastRow = ActiveSheet.Cells(65536, lastCol).End(xlUp).Row
ActiveSheet.Range("a1", ActiveSheet.Cells(lastRow, lastCol)).Select