Skip to content

Instantly share code, notes, and snippets.

@znz
Last active October 26, 2016 12:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save znz/a6de602c03fbd6e50c172437a855f4dd to your computer and use it in GitHub Desktop.
Save znz/a6de602c03fbd6e50c172437a855f4dd to your computer and use it in GitHub Desktop.
Excel and LibreOffice behave differently.
# -*- coding: utf-8 -*-
# frozen_string_literal: true
require 'axlsx'
package = Axlsx::Package.new
package.use_shared_strings = true # for Numbers
wb = package.workbook
gridstyle_border = wb.styles.add_style border: { style: :thin, color: 'FFCDCDCD' }
wb.add_worksheet do |sheet|
sheet.sheet_view.show_grid_lines = false
sheet.add_row []
sheet.add_row [nil, 'foo', 'bar', 'baz'], style: [nil, gridstyle_border, gridstyle_border, gridstyle_border]
sheet.merge_cells 'B2:D2'
sheet.add_row []
sheet.add_row [nil, 'foo', 'bar', 'baz'], style: [nil, gridstyle_border, nil, gridstyle_border]
sheet.merge_cells 'B4:D4'
end
package.serialize(File.basename(__FILE__).sub(/\.rb\z/, '.xlsx'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment