Created
January 30, 2014 12:26
-
-
Save morganchristiansson/8707434 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'spreadsheet' | |
input_path = ARGV[0] or abort('Expecting .xls file as argument') | |
output_path = input_path.sub(/\.xls$/, '-out.xls') | |
book = Spreadsheet.open(input_path) | |
# This is a fix/workaround - modifying each sheet in the workbook. | |
# Without it, the output file doesn't open at all | |
# | |
# After resaving the file in Excel for Mac 2011 the output file | |
# generates warning on open and is sometimes missing data | |
# | |
book.worksheets.each do |sheet| | |
sheet.each(0) { |row| row.replace row } | |
end | |
# Without the code above this line breaks the output file completley | |
book.worksheet(0).row(0)[0] = '' | |
book.write(output_path) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment