Skip to content

Instantly share code, notes, and snippets.

@shellac
Created August 23, 2010 14:41
Show Gist options
  • Save shellac/545607 to your computer and use it in GitHub Desktop.
Save shellac/545607 to your computer and use it in GitHub Desktop.
require 'java'
require 'jOpenDocument-1.0.jar'
include_class 'javax.swing.table.AbstractTableModel'
include_class 'org.jopendocument.dom.spreadsheet.SpreadSheet'
include_class 'org.jopendocument.dom.OOUtils'
class MyTable < AbstractTableModel
def initialize
@data = [['a',1.0],['b',2.0]]
@cols = ['month', 'temp']
end
def getRowCount; @data.size; end
def getColumnCount; @cols.size; end
def getValueAt(row, col); @data[row][col]; end
end
model = MyTable.new
file = java.io.File.new('temp.ods')
SpreadSheet.create_empty(model).save_as(file)
OOUtils.open(file)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment