Skip to content

Instantly share code, notes, and snippets.

@mallorydxw
mallorydxw / xlsx2csv.rb
Created December 2, 2013 19:46
Apparently converting XLSX to CSV and keeping formulae intact is not something you can Google and find out how to do it? This is how you do it.
#!/usr/bin/env ruby
require 'rubygems'
require 'csv'
require 'roo'
excel = Roo::Excelx.new('filename.xlsx')
CSV do |csv| # (stdout)
int64_t ipow(int64_t base, uint8_t exp) {
static const uint8_t highest_bit_set[] = {
0, 1, 2, 2, 3, 3, 3, 3,
4, 4, 4, 4, 4, 4, 4, 4,
5, 5, 5, 5, 5, 5, 5, 5,
5, 5, 5, 5, 5, 5, 5, 5,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 6,
6, 6, 6, 6, 6, 6, 6, 255, // anything past 63 is a guaranteed overflow with base > 1