在Php中复制和移动工作表

Aspose.Cells - 复制和移动工作表

在工作簿内复制工作表

使用PHP中的Aspose.Cells for Java复制工作表,调用copyworksheets模块的copy_worksheet方法。以下是代码示例。

PHP 代码

 # Create a Worksheets object with reference to the sheets of the Workbook.

$sheets = $workbook->getWorksheets();

\# Copy data to a new sheet from an existing sheet within the Workbook.

$sheets->addCopy("Sheet1");

\# Saving the modified Excel file in default (that is Excel 2003) format

$workbook->save($dataDir . "Copy Worksheet.xls");

在工作簿内移动工作表

使用PHP中的Aspose.Cells for Java移动工作表,调用copyworksheets模块的move_worksheet方法。以下是代码示例。

PHP 代码

 # Get the first worksheet in the book.

$sheet = $workbook->getWorksheets()->get(0);

\# Move the first sheet to the third position in the workbook.

$sheet->moveTo(2);

\# Saving the modified Excel file in default (that is Excel 2003) format

$workbook->save($dataDir . "Move Worksheet.xls");

下载运行代码

从以下任何社交编程网站下载复制和移动工作表(Aspose.Cells)