Reputation: 946
I am using the following Spreadsheet gem to generate an excel sheet from ruby-on-rails.. http://spreadsheet.rubyforge.org/GUIDE_txt.html
I want to format a cell such that I can see it's top and bottom border, but not any other. Is there anybody who's been there and done that, and knows how to?
http://spreadsheet.rubyforge.org/Spreadsheet/Format.html
The - (Object) border=(boolean) Activate or deactivate all four borders (left, right, top, bottom).
Upvotes: 1
Views: 6600
Reputation: 11
Here are a few examples with Spreadsheet gem.
#Defining formats
float_format = Spreadsheet::Format.new :number_format => "#,##0"
percent_format = Spreadsheet::Format.new :number_format => "0.00%"
bold_format = Spreadsheet::Format.new :weight => :bold
cell_format = Spreadsheet::Format.new :bottom => :medium,
:horizontal_align => :center,
:weight => :bold
#Implementation
sheet.default_format = float_format. #Format sheet
sheet.column(col_idx).default_format = percent_format #Format a column
sheet.row(row_idx).default_format = bold_format #Format a row
sheet.row(row_idx).set_format(col_idx, cell_format) #Format a cell
sheet.column(1).width = 12 #Format column width
Reference:https://github.com/zdavatz/spreadsheet/blob/master/lib/spreadsheet/format.rb
Upvotes: 1
Reputation: 876
How about this:
book = Spreadsheet::Workbook.new
sheet = book.create_worksheet
format = Spreadsheet::Format.new
format.bottom = true
format.top = true
sheet.rows[4].set_format(8, format)
Upvotes: 6
Reputation: 36
If you are generating excel, axlsx and the rails plugin acts_as_xlsx is probably your best bet.
http://rubygems.org/gems/axlsx
Upvotes: 2
Reputation: 6728
Hi I am not sure but this gem might be helpful to you.
Upvotes: 0