Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.
Sometimes, you need to copy rows and columns in a worksheet without copying the entire worksheet. With Aspose.Cells, it is possible to copy rows and columns within or between workbooks.
When a row (or column) is copied, the data contained in it, including formulas—with updated references—and values, comments, formatting, hidden cells, images, and other drawing objects are copied too.
Aspose.Cells provides the copy_row method of the Cells class. This method copies all types of data including formulas, values, comments, cell formats, hidden cells, images, and other drawing objects from the source row to the destination row.
The copy_row method takes the following parameters:
Use this method to copy a row within a sheet, or to another sheet. The copy_row method works in a similar way to Microsoft Excel. So, for example, you don’t need to set the height of the destination row explicitly; that value is copied too.
The following example shows how to copy a row in a worksheet. It uses a template Microsoft Excel file, copies the second row (complete with data, formatting, comments, images, and so on), and pastes it to the 12th row in the same worksheet.
You can skip the step that gets the source row height using the Cells.get_row_height method and then set the destination row height using the Cells.set_row_height method, as the copy_row method automatically takes care of the row height.
When copying rows, it is important to note related images, charts, or other drawing objects, as this is the same in Microsoft Excel:
You can also copy multiple rows onto a new destination while using the Cells.copy_rows method, which takes an additional integer parameter to specify the number of source rows to be copied.
Aspose.Cells provides the copy_column method of the Cells class. This method copies all types of data, including formulas—with updated references—values, comments, cell formats, hidden cells, images, and other drawing objects from the source column to the destination column.
The copy_column method takes the following parameters:
Use the copy_column method to copy a column within a sheet or to another sheet.
This example copies a column from a worksheet and pastes it into a worksheet in another workbook.
Similar to the Cells.copy_rows method, the Aspose.Cells APIs also provide the Cells.copy_columns method in order to copy multiple source columns to a new location.
Aspose.Cells now provides PasteOptions while using the functions copy_rows and copy_columns. It allows you to set appropriate paste options similar to Excel.
Analyzing your prompt, please hold on...
An error occurred while retrieving the results. Please refresh the page and try again.