Sha256: 8092a5df8e632f1f73e0bcea445bc72a7a7184338b84dc6cd13fb35153e9a183
Contents?: true
Size: 1.42 KB
Versions: 3
Compression:
Stored size: 1.42 KB
Contents
module Asposecellsjava module CopyWorksheets def initialize() @data_dir = File.dirname(File.dirname(File.dirname(__FILE__))) + '/data/' # Instantiating a Workbook object by excel file path workbook = Rjb::import('com.aspose.cells.Workbook').new(@data_dir + 'Book1.xls') # Copy Worksheets within a Workbook copy_worksheet(workbook) # Move Worksheets within Workbook move_worksheet(workbook) end 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 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 end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
asposecellsjava-0.0.3 | lib/asposecellsjava/copyworksheets.rb |
asposecellsjava-0.0.2 | lib/asposecellsjava/copyworksheets.rb |
asposecellsjava-0.0.1 | lib/asposecellsjava/copyworksheets.rb |