在工作表中移动范围 Cells

在工作表中移动范围 Cells

示例代码使用模板文件来演示任务。

输入文件

待办事项:图片_替代_文本

请查看以下生成的文件,范围 A1:B5 已移至 C1:D5。

输出文件

待办事项:图片_替代_文本

// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java
// The path to the documents directory.
String dataDir = Utils.getDataDir(MoveRangeOfCellsInWorksheet.class);
// Instantiate the workbook object. Open the Excel file
Workbook workbook = new Workbook(dataDir + "book1.xls");
Cells cells = workbook.getWorksheets().get(0).getCells();
// Create Cell's area
CellArea ca = CellArea.createCellArea("A1", "B5");
// Move Range
cells.moveRange(ca, 0, 2);
// Save the resultant file
workbook.save(dataDir + "book2.xls");