Skip to content

Instantly share code, notes, and snippets.

Last active Oct 26, 2016
What would you like to do?
Excel and LibreOffice behave differently.
# -*- coding: utf-8 -*-
# frozen_string_literal: true
require 'axlsx'
package =
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'
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