Write to a cross-platform Excel binary file.
This library is converted from Spreadsheet::WriteExcel module of Perl. search.cpan.org/~jmcnamara/Spreadsheet-WriteExcel-2.38/
Original description is below:
The Spreadsheet::WriteExcel module can be used to create a cross- platform Excel binary file. Multiple worksheets can be added to a workbook and formatting can be applied to cells. Text, numbers, formulas, hyperlinks, images and charts can be written to the cells. TThe Excel file produced by this module is compatible with 97, 2000, 2002, 2003 and 2007. The module will work on the majority of Windows, UNIX and Macintosh platforms. Generated files are also compatible with the spreadsheet applications Gnumeric and OpenOffice.org. This module cannot be used to read an Excel file.
Add this line to your application’s Gemfile:
gem 'writeexcel'
And then execute:
$ bundle
Or install it yourself as:
$ gem install writeexcel
See Reference writeexcel.web.fc2.com/ . You must save source file in UTF8, and run ruby with -Ku option or set $KCODE=‘u’ in Ruby 1.8.
Example Code:
require 'writeexcel' # Create a new Excel Workbook workbook = WriteExcel.new('ruby.xls') # Add worksheet(s) worksheet = workbook.add_worksheet worksheet2 = workbook.add_worksheet # Add and define a format format = workbook.add_format format.set_bold format.set_color('red') format.set_align('right') # write a formatted and unformatted string. worksheet.write(1, 1, 'Hi Excel.', format) # cell B2 worksheet.write(2, 1, 'Hi Excel.') # cell B3 # write a number and formula using A1 notation worksheet.write('B4', 3.14159) worksheet.write('B5', '=SIN(B4/4)') # write to file workbook.close
-
WriteExcel.new()
-
accept default format parameter such as new(‘foo.xls’, :font => ‘Roman’, :size => 12)
-
-
Unary minus is supported, but it will be stored as ‘-1*’. ex) ‘=-1’ -> ‘=-1*1’, ‘=-SIN(PI()/2)’ => ‘=-1*SIN(PI()/2)’
-
Worksheet.write(row, col, token, format)
-
if token.kind_of?(Numeric) then call write_number, if token.kind_of?(String) then not call write_number().
-
-
Worksheet.keep_leading_zeros()
-
ignore. if write 0001, use string such as write(1,2, ‘0001’)
-
-
and .…..
v1.0.0
-
Bug fix in Workbook#set_properties.
v0.6.19
-
Bug fix in Worksheet#write_url_internal
v0.6.18
-
Bug fix in compatibility_mode (Worksheet#write_number).
v0.6.17
-
Bug fix in compatibility_mode (Worksheet#write_string).
v0.6.16
-
typo fix
v0.6.15
-
add Worksheet#merge_range_with_date_time : write datetime string to merged cells
v0.6.14
-
Buf fix Issues 20. If more than 10 sheets, sheet reference mix up
v0.6.13
-
Bug fix issue 19. Workbook#store_num_format, format written in utf8 raise exception.
v0.6.12
-
Bug fix issue 17. Worksheet#store_formula shouldn’t be private
v0.6.11
-
Bug fix issue 15. Worksheet#write_comment on the same row overwrite other comments.
v0.6.10
-
Bug fix. method missing split_string_setup() in shared_string_table.rb. see github.com/cxn03651/writeexcel/pull/13
v0.6.9
-
Bug fix. When sheetname is cell’s A1 notation such as ‘D1’, Worksheet#autofilter causes exception.
v0.6.8
-
Bug fix. Worksheet#protect doesn’t work well.
v0.6.7
-
Bug fix. Worksheet#set_first_sheet doesn’t work well.
-
Bug fix. Worksheet#hide_zero doesn’t work well.
-
Bug fix. Worksheet#set_column - col width doesn’t set to zero when pass hidden 1.
‘ v0.6.6
-
add private method to avoid warning: private attribute?
v0.6.5
-
Bug fix. if workbook already has worksheet of utf8 name, Workbook#add_worksheet, Workbook#add_chart, Workbook#add_chart_ext raise exception when add new worksheet of utf8 name.
v0.6.4
-
Bug fix. endless loop when inserted image size > 8224bytes.
v0.6.3
-
Bug fix. endless loop when inserted image size > 8224.
v0.6.1
-
Bug fix. to avoid output stack trace for debug when defined $debug such as Rails 2.3.8 development console.
v0.6.0
-
Bug fix. to avoid destroy to_json method when using with Rails 3
Original was written in Perl by John McNamara ([email protected]).
Convert to ruby by Hideo Nakamura ([email protected]) Copyright © 2009-2013 Hideo NAKAMURA. See LICENSE for details.
See LICENSE.txt
-
Fork it
-
Create your feature branch (‘git checkout -b my-new-feature`)
-
Commit your changes (‘git commit -am ’Add some feature’‘)
-
Push to the branch (‘git push origin my-new-feature`)
-
Create new Pull Request