Spreadsheet can work in IRB. Try this:
book = Spreadsheet.open(“foo.xls”) and true
book.worksheets
Spreadsheet can work in IRB. Try this:
book = Spreadsheet.open(“foo.xls”) and true
book.worksheets
Ruby Spreadsheet License Version 0.11
1. The purpose of this license is to allow “Company” the usage of the Ruby Spreadsheet Library by ywesee GmbH up to Version 2.0. The current version is 1.0.0. All versions of the Software can be found at https://github.com/zdavatz/spreadsheet
2. The reason for this license is that “Company” does not want to use Spreadsheet under GPLv3.
3. “Company” is allowed to use the above software on two servers. The Use Case for “Company” is: “Use-Case-Text.”
4. “Company” is allowed to use Spreadsheet as noted under point three.
5. Except otherwise stated in this contract, “Company” is not allowed to resell, reuse or give away any version of above code under any other licence then the GPLv3.
6. “Company” will pay a onetime fee of USD xxxx excl. VAT for the usage of Spreadsheet up to Version 2.0. The fee is due once this contract has been agreed upon by both parties. The invoice willbe sent to “Company” via Email.
7. ywesee GmbH will work towards fixing any bug submitted via https://github.com/zdavatz/spreadsheet/issues . Issues that are estimated to require more than 2 workdays to correct may be subject to a fee, which will be negotiated prior to the work.
8. The court of jurisdiction is Zürich, Switzerland.
Please note: If a bug occurs in Version 1.9999 to Version 2.0 and you or anybody else reports that bug, then we will fix it not matter what. If a bug occurs in Version 2.01 to Version 2.02 then of course we will have to renegotiate the terms of our contract and the price for Version 2.0 up to Version 3.0.We will not “create” a bug in Version pre 2.0 and then ask for money for Version 3.0. Version 2.0 will include many bug and Feature improvements a long way from the current version (if you look at the current Version History you can see our track Record and we will not do a release for “money making reasons”). So to cover our work we need to cover our expenses.
To see the Ruby Spreadsheet Track History, please see:
https://github.com/zdavatz/spreadsheet/blob/master/History.md
To see the Ruby Spreadsheet RoadMap, please see:
https://github.com/zdavatz/spreadsheet/blob/master/README.md
This question has been asked many times on the mailing list:
I have an Excel file (workbook) with many worksheets in it. Now I modify one worksheet but leave the other worksheets untouched. When I write the file and then try to open it with OpenOffice or Microsoft Office the file hangs. What do I have to do?
1. You need to write the modified file to a new file name.
2. If the Workbook contains empty sheets, delete the empty sheets from the source file. There is no point in carrying empty sheets around.
3. If the Workbook contains 1 sheet that you want to modify but you want to leave the other worksheets untouched because they contain data, then read the following post from John Smith (very smart guy).
http://groups.google.com/group/rubyspreadsheet/browse_thread/thread/f5bc157b06b66604
4. If you find a better solution, let me know via the list – and do not forget to post your sample code to github (please do not post it in the mail).
Thanks to Alexandre Bini for this update. See: http://url.ba/ery3
PS: A lot of questions have already been answered here:
If you are using Ruby-Spreadsheet to edit existing Excel Files then we have a new feature for you: Hiding, Unhiding, and Outlining of columns and lines is now possible with Ruby-Spreadsheet 0.6.5.
You can create a new file with outline and hiding rows and columns as
follows:
require ‘spreadsheet’
# create a new book and sheet
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet
5.times {|j| 5.times {|i| sheet[j,i] = (i+1)*10**j}}# column
sheet.column(2).hidden = true
sheet.column(3).hidden = true
sheet.column(2).outline_level = 1
sheet.column(3).outline_level = 1# row
sheet.row(2).hidden = true
sheet.row(3).hidden = true
sheet.row(2).outline_level = 1
sheet.row(3).outline_level = 1# save file
book.write ‘out.xls’
gem and gemspec for ruby spreadsheet 0.6.5 can be found here. Hit the “Blob” link to download the gem.
# This deletes the highest outline level
require ‘spreadsheet’
file = ARGV[0]
book = Spreadsheet.open(file, ‘rb’)
sheet= book.worksheet(0)26.upto(30) do |i|
sheet.row(i).outline_level = 4
endbook.write “out.xls”
# This hides the rows in the highest level of outline
require ‘spreadsheet’
file = ARGV[0]
book = Spreadsheet.open(file, ‘rb’)
sheet= book.worksheet(0)26.upto(30) do |i|
sheet.row(i).hidden = true
endbook.write “out.xls”
See the sample file. Sample Nested Outline for Ruby-Spreadsheet 0.6.5.
Obviously Formula support is the single most wanted feature for Ruby-Spreadsheet. This will come, we just do not know when. In the meantime we fixed two bugs:
check it out at: http://scm.ywesee.com/?p=spreadsheet/.git;a=summary
* Reduce warnings produced by running under ruby -w
* Improved auto-formatting for Dates and Times
* Honor Row, Column, Worksheet and Workbook-formats
* Merge branch ‘master’ into HEAD
* Only select the First Worksheet by default
Ruby Spreadsheet Licence Version 0.11
1. The purpose of this license is to allow XCompany.com the usage of the Ruby Spreadsheet Library by ywesee GmbH up to Version 1.0. The current version is 0.6.5.4. All versions of the Software can be found at http://scm.ywesee.com/?p=spreadsheet/.git;a=summary
2. The reason for this licence is that XCompany.com does not want to use Spreadsheet under GPLv3.
3. XCompany.com is allowed to use above software on two servers. XCompany.com is allowed to use the above software within their software for their purpose according to their User-Story. According to Name Surname the User-Story is “It would form part of an ‘export these records to …’ feature on our website and as such it would sit alongside export options to PDF, CSV, HTML etc. So it would be part of a service.”
4. XCompany.com is allowed to use Spreadsheet as noted under point three.
5. Except otherwise stated in this contract, XCompany.com is not allowed to resell, reuse or give away any version of above code under any other licence then the GPLv3.
6. XCompany.com will pay a onetime fee of EUR X for the usage of Spreadsheet up to Version 1.0. The fee is due once this contract has been agreed upon by both parties. The invoice will be sent to XCompany.com via Email.
7. ywesee GmbH will work towards fixing any bug submitted via http://rubyforge.org/tracker/?atid=2677&group_id=678&func=browse. Issues that are estimated to require more than 2 workdays to correct may be subject to a fee, which will be negotiated prior to the work.
8. The court of jurisdiction is Zürich, Switzerland.
Please note: If a bug occurs in Version 0.9999 to Version 1.0 and you or anybody else reports that bug, then we will fix it not matter what. If a bug occurs in Version 1.01 to Version 1.02 then of course we will have to renegotiate the terms of our contract and the price for Version 1.0 up to Version 2.0.
We will not “create” a bug in Version pre 1.0 and then ask for money for Version 1.0. Version 1.0 will include many bug and Feature improvements a long way from the current version (if you look at the current Version History you can see our track Record and we will not do a realese for “money makeing reasons”). So to cover our work we need to cover our expenses.
To see the Ruby Spreadsheet Track History, please see:
http://spreadsheet.rubyforge.org/files/History_txt.html
To see the Ruby Spreadsheet RoadMap, please see:
http://spreadsheet.rubyforge.org
http://scm.ywesee.com/?p=spreadsheet;a=summary
The Spreadsheet Library is designed to read and write Spreadsheet
Documents. As of version 0.6.0, only Microsoft Excel compatible
spreadsheets are supported. Spreadsheet is a combination/complete
rewrite of the Spreadsheet::Excel Library by Daniel J. Berger and the
ParseExcel Library by Hannes Wyss. Spreadsheet can read, write and
modify Spreadsheet Documents.
Changes:
### 0.6.0 / 2008-10-13
Initial upload of the shiny new Spreadsheet Gem after three weeks of
grueling labor in the dark binary mines of Little-Endian Biff and long
hours spent polishing the surfaces of documentation:
* Significantly improved memory-efficiency when reading large Excel Files
* Limited Spreadsheet modification support
* Improved handling of String Encodings
* Runs on top of the ruby-ole Library
Roadmap:
0.7.0: Improved Format support/Styles
0.7.1: Document Modification: Formats/Styles
0.8.0: Formula Support
0.8.1: Document Modification: Formulas
0.9.0: Write-Support: BIFF5
1.0.0: Ruby 1.9 Support;
Remove backward compatibility code
Backward Compatibility:
Spreadsheet is designed to be a drop-in replacement for both
ParseExcel and Spreadsheet::Excel. It provides a number of
require-paths for backward compatibility with its predecessors. If you
have been working with ParseExcel, you have probably used one or more
of the following:
require ‘parseexcel’
require ‘parseexcel/parseexcel’
require ‘parseexcel/parser’
Either of the above will define the ParseExcel.parse method as a
facade to Spreadsheet.open. Additionally, this will alter Spreadsheets
behavior to define the ParseExcel::Worksheet::Cell class and fill each
parsed Row with instances thereof, which in turn provide ParseExcel’s
Cell#to_s(encoding) and Cell#date methods.
You will have to manually uninstall the parseexcel library.
If you are upgrading from Spreadsheet::Excel, you were probably using
Workbook#add_worksheet and Worksheet#write, write_row or write_column.
Use the following to load the code which provides them:
require ‘spreadsheet/excel’
Again, you will have to manually uninstall the spreadsheet-excel library.
If you perform fancy formatting, you may run into trouble as the
Format implementation has changed considerably. If that is the case,
please drop me a line at hannes.wyss@gmail.com and I will try to help
you. Don’t forget to include the offending code-snippet!