Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Whether creating a new worksheet from scratch or working on an existing worksheet, we may need to add extra rows or columns to accommodate more data. Inversely, we may also need to delete rows or columns from specified positions in the worksheet.
To fulfill these requirements, Aspose.Cells provides a very simple set of classes and methods, discussed below.
Aspose.Cells provides a class Workbook that represents a Microsoft Excel file. The Workbook class contains a Worksheets collection that allows access to each worksheet in an Excel file. A worksheet is represented by the Worksheet class. The Worksheet class provides a Cells collection that represents all cells in the worksheet.
The Cells collection provides several methods for managing rows and columns in a worksheet. Some of these are discussed below.
Insert a row into the worksheet at any location by calling the InsertRow method of the Cells collection. The InsertRow method takes the index of the row where the new row will be inserted.
Compared to inserting one row at a time, the InsertRows method allows you to insert multiple rows at once, which greatly improves row insertion performance. As multiple rows are inserted, elements such as formulas, shapes, data and charts will move accordingly. To insert multiple rows into a worksheet, call the InsertRows method of the Cells collection. The InsertRows method takes two parameters:
To insert a row with formatting options, use the InsertRows overload that takes InsertOptions as a parameter. Set the CopyFormatType property of the InsertOptions class with the CopyFormatType enumeration. The CopyFormatType enumeration has three members as listed below.
Developers can also insert a column into the worksheet at any location by calling the InsertColumn method of the Cells collection. The InsertColumn method takes the index of the column where the new column will be inserted.
To delete multiple rows from a worksheet, call the DeleteRows method of the Cells collection. The DeleteRows method takes two parameters:
To delete a column from the worksheet at any location, call the DeleteColumn method of the Cells collection. The DeleteColumn method takes the index of the column to delete.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.