在 Ruby 中复制和移动工作表

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

在工作簿中复制工作表

使用复制工作表红宝石中的 Aspose.Cells for Java, 称呼复制工作表的方法抄作业模块。您可以在下面看到代码示例。

红宝石代码

 def copy_worksheet(workbook)

    # 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(@data_dir + "Copy Worksheet.xls")

    puts "Copy worksheet, please check the output file."

end 

在工作簿中移动工作表

使用移动工作表红宝石中的 Aspose.Cells for Java, 称呼移动工作表的方法抄作业模块。您可以在下面看到代码示例。

红宝石代码

 def move_worksheet(workbook)

    # 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(@data_dir + "Move Worksheet.xls")

    puts "Move worksheet, please check the output file."

end 

下载运行代码

下载**复制和移动工作表 (Aspose.Cells)**来自以下任何社交编码网站: