Class: Workbook
- Inherits:
-
Object
- Object
- Workbook
- Defined in:
- lib/jruby_excelcom/workbook.rb
Instance Method Summary collapse
-
#add_worksheet(name) ⇒ Object
(also: #addWorksheet)
- adds and returns a worksheet to this workbook
name
-
name of new worksheet.
- adds and returns a worksheet to this workbook
-
#close(save = false) ⇒ Object
- closes this workbook
save
-
whether changes should be saved or not, default is
false
.
- closes this workbook
-
#initialize(java_wb) ⇒ Workbook
constructor
A new instance of Workbook.
-
#name ⇒ Object
(also: #getName)
gets the name of this workbook.
-
#save ⇒ Object
saves this workbook.
-
#save_as(path) ⇒ Object
(also: #saveAs)
saves this workbook to a new location.
-
#worksheet(name) ⇒ Object
(also: #getWorksheet)
- gets a worksheet
name
-
name of worksheet to get.
- gets a worksheet
Constructor Details
#initialize(java_wb) ⇒ Workbook
Returns a new instance of Workbook.
5 6 7 |
# File 'lib/jruby_excelcom/workbook.rb', line 5 def initialize(java_wb) @wb = java_wb end |
Instance Method Details
#add_worksheet(name) ⇒ Object Also known as: addWorksheet
adds and returns a worksheet to this workbook
name
-
name of new worksheet
34 35 36 |
# File 'lib/jruby_excelcom/workbook.rb', line 34 def add_worksheet(name) Worksheet.new(@wb.addWorksheet(name)) end |
#close(save = false) ⇒ Object
closes this workbook
save
-
whether changes should be saved or not, default is
false
17 18 19 |
# File 'lib/jruby_excelcom/workbook.rb', line 17 def close(save = false) @wb.close(save) end |
#name ⇒ Object Also known as: getName
gets the name of this workbook
10 11 12 |
# File 'lib/jruby_excelcom/workbook.rb', line 10 def name @wb.getName end |
#save ⇒ Object
saves this workbook
22 23 24 |
# File 'lib/jruby_excelcom/workbook.rb', line 22 def save @wb.save end |
#save_as(path) ⇒ Object Also known as: saveAs
saves this workbook to a new location. Every further operations on this workbook will happen to the newly saved file.
27 28 29 |
# File 'lib/jruby_excelcom/workbook.rb', line 27 def save_as(path) @wb.saveAs(java.io.File.new(path)) end |