Skip to content

AppendRange.cs

Avrigeanu Laurian edited this page Apr 12, 2023 · 1 revision

AppendRange(object sheet, int startRow, int startColumn, object[,] values)

Parameters

  • sheet (object): The name or index of the worksheet to append the range to.
  • startRow (int): The starting row index of the range to append.
  • startColumn (int): The starting column index of the range to append.
  • values (object[,]): The two-dimensional array of values to append to the worksheet.

Returns

This method does not return anything.

Remarks

This method appends a two-dimensional array of values to a specified range in a worksheet. The sheet parameter can be either the name or the index of the worksheet to append the range to. The startRow parameter specifies the starting row index of the range, and the startColumn parameter specifies the starting column index of the range.

The values parameter is a two-dimensional array of objects that contains the values to append to the worksheet. The size of the array determines the size of the range to append. The first dimension of the array corresponds to the rows in the range, and the second dimension corresponds to the columns.

This method uses the Microsoft.Office.Interop.Excel namespace to access and manipulate Excel workbooks and worksheets. It creates a Range object that represents the target range to append to, and sets the Value2 property of the range to the values parameter.

After the range is appended, this method releases the COM objects used by the Range and Worksheet objects to free up memory. It is important to call this method to avoid memory leaks when using the Microsoft.Office.Interop.Excel namespace.

Clone this wiki locally