Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 85f62df
Showing
26 changed files
with
919 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
.DS_Store | ||
.project | ||
.idea | ||
nbproject | ||
.*~ | ||
tmp | ||
*.swp | ||
TAGS |
Large diffs are not rendered by default.
Oops, something went wrong.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
Apache POI | ||
Copyright 2009 The Apache Software Foundation | ||
|
||
This product includes software developed by | ||
The Apache Software Foundation (http://www.apache.org/). | ||
|
||
This product contains the DOM4J library (http://www.dom4j.org). | ||
Copyright 2001-2005 (C) MetaStuff, Ltd. All Rights Reserved. | ||
|
||
This product contains parts that were originally based on software from BEA. | ||
Copyright (c) 2000-2003, BEA Systems, <http://www.bea.com/>. | ||
|
||
This product contains W3C XML Schema documents. Copyright 2001-2003 (c) | ||
World Wide Web Consortium (Massachusetts Institute of Technology, European | ||
Research Consortium for Informatics and Mathematics, Keio University) | ||
|
||
This product contains the Piccolo XML Parser for Java | ||
(http://piccolo.sourceforge.net/). Copyright 2002 Yuval Oren. | ||
|
||
This product contains the chunks_parse_cmds.tbl file from the vsdump program. | ||
Copyright (C) 2006-2007 Valek Filippov (frob@df.ru) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
jruby-poi | ||
========= | ||
|
||
This little gem provides an alternative interface to the Apache POI java library, for jruby. | ||
|
||
INSTALL: | ||
======== | ||
|
||
* gem install jruby-poi | ||
|
||
Contributors | ||
============ | ||
|
||
* [Scott Deming](http://github.com/sdeming) | ||
|
||
Note on Patches/Pull Requests | ||
============================= | ||
|
||
* Fork the project. | ||
* Make your feature addition or bug fix. | ||
* Add tests for it. This is important so I don't break it in a future version unintentionally. | ||
* Commit, do not mess with rakefile, version, or history. | ||
(if you want to have your own version, that is fine but bump version in a commit by itself I can ignore when I pull) | ||
* Send me a pull request. | ||
|
||
Copyright | ||
========= | ||
|
||
Copyright (c) 2010 Scott Deming and others. | ||
See NOTICE and LICENSE for details. | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
begin | ||
require 'jeweler' | ||
Jeweler::Tasks.new do |gemspec| | ||
gemspec.name = "jruby-poi" | ||
gemspec.summary = "Apache POI class library for jruby" | ||
gemspec.description = "A rubyesque library for manipulating spreadsheets and other document types for jruby, using Apache POI." | ||
gemspec.email = "sdeming@makefile.com" | ||
gemspec.homepage = "http://github.com/sdeming/jruby-poi" | ||
gemspec.authors = ["Scott Deming"] | ||
end | ||
rescue LoadError | ||
puts "Jeweler not available. Install it with: gem install jeweler" | ||
end | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
JRUBY_POI_LIB_PATH=File.expand_path(File.dirname(__FILE__)) | ||
|
||
# Java | ||
require 'java' | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi-3.6-20091214.jar') | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi-ooxml-3.6-20091214.jar') | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi-ooxml-schemas-3.6-20091214.jar') | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi-scratchpad-3.6-20091214.jar') | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi-contrib-3.6-20091214.jar') | ||
require File.join(JRUBY_POI_LIB_PATH, 'ooxml-lib', 'xmlbeans-2.3.0.jar') | ||
require File.join(JRUBY_POI_LIB_PATH, 'ooxml-lib', 'dom4j-1.6.1.jar') | ||
|
||
# Ruby | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi', 'workbook') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi', 'workbook', 'workbook') | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi', 'workbook', 'worksheet') | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi', 'workbook', 'row') | ||
require File.join(JRUBY_POI_LIB_PATH, 'poi', 'workbook', 'cell') |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module POI | ||
class Cells | ||
include Enumerable | ||
|
||
def initialize(row) | ||
@row = row | ||
@poi_row = row.poi_row | ||
end | ||
|
||
def [](index) | ||
Cell.new(@poi_row.getCell(index)) | ||
end | ||
|
||
def size | ||
@poi_row.getPhysicalNumberOfCells | ||
end | ||
|
||
def each | ||
it = @poi_row.cellIterator | ||
yield Cell.new(it.next) while it.hasNext | ||
end | ||
end | ||
|
||
class Cell | ||
def initialize(cell) | ||
@cell = cell | ||
end | ||
|
||
def index | ||
@cell.getColumnIndex | ||
end | ||
|
||
def to_s | ||
@cell.getStringCellValue | ||
end | ||
|
||
def poi_cell | ||
@cell | ||
end | ||
end | ||
end | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
module POI | ||
class Rows | ||
include Enumerable | ||
|
||
def initialize(worksheet) | ||
@worksheet = worksheet | ||
@poi_worksheet = worksheet.poi_worksheet | ||
end | ||
|
||
def [](index) | ||
Row.new(@poi_worksheet.getRow(index)) | ||
end | ||
|
||
def size | ||
@poi_worksheet.getPhysicalNumberOfRows | ||
end | ||
|
||
def each | ||
it = @poi_worksheet.rowIterator | ||
yield Row.new(it.next) while it.hasNext | ||
end | ||
end | ||
|
||
class Row | ||
def initialize(row) | ||
@row = row | ||
end | ||
|
||
def cells | ||
Cells.new(self) | ||
end | ||
|
||
def index | ||
@row.getRowNum | ||
end | ||
|
||
def poi_row | ||
@row | ||
end | ||
end | ||
end | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
module POI | ||
class Workbook | ||
def self.open(filename) | ||
raise Exception, "FileNotFound" unless File.exists? filename | ||
instance = self.new(filename) | ||
|
||
if block_given? | ||
result = yield instance | ||
return result | ||
end | ||
|
||
instance | ||
end | ||
|
||
def initialize(filename) | ||
@filename = filename | ||
@workbook = org.apache.poi.ss.usermodel.WorkbookFactory.create(java.io.FileInputStream.new(filename)) | ||
end | ||
|
||
def save | ||
@workbook.write(java.io.FileOutputStream.new(@filename)) | ||
end | ||
|
||
def save_as(filename) | ||
@workbook.write(java.io.FileOutputStream.new(filename)) | ||
end | ||
|
||
def close | ||
#noop | ||
end | ||
|
||
def worksheets | ||
Worksheets.new(self) | ||
end | ||
|
||
def poi_workbook | ||
@workbook | ||
end | ||
end | ||
end | ||
|
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
module POI | ||
class Worksheets | ||
include Enumerable | ||
|
||
def initialize(workbook) | ||
@workbook = workbook | ||
@poi_workbook = workbook.poi_workbook | ||
end | ||
|
||
def [](index) | ||
worksheet = case | ||
when index.kind_of?(Numeric) | ||
@poi_workbook.getSheetAt(index) | ||
else | ||
@poi_workbook.getSheet(index) | ||
end | ||
Worksheet.new(worksheet) | ||
end | ||
|
||
def size | ||
@poi_workbook.getNumberOfSheets | ||
end | ||
|
||
def each | ||
(0...size).each { |i| yield Worksheet.new(@poi_workbook.getSheetAt(i)) } | ||
end | ||
end | ||
|
||
class Worksheet | ||
def initialize(worksheet = nil) | ||
@worksheet = worksheet | ||
end | ||
|
||
def name | ||
@worksheet.getSheetName | ||
end | ||
|
||
def rows | ||
Rows.new(self) | ||
end | ||
|
||
def poi_worksheet | ||
@worksheet | ||
end | ||
end | ||
end | ||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
require File.join(File.dirname(__FILE__), 'spec_helper') | ||
|
||
describe POI::Workbook do | ||
it "should read an xlsx file" do | ||
name = TestDataFile.expand_path("simple_with_picture.xlsx") | ||
book = nil | ||
lambda { book = POI::Workbook.open(name) }.should_not raise_exception | ||
book.should be_kind_of POI::Workbook | ||
end | ||
|
||
it "should read an xls file" do | ||
name = TestDataFile.expand_path("simple_with_picture.xls") | ||
book = nil | ||
lambda { book = POI::Workbook.open(name) }.should_not raise_exception | ||
book.should be_kind_of POI::Workbook | ||
end | ||
|
||
it "should read an ods file" do | ||
pending "get a valid, non excel produced ods file" do | ||
name = TestDataFile.expand_path("simple_with_picture.ods") | ||
book = nil | ||
lambda { book = POI::Workbook.open(name) }.should_not raise_exception | ||
book.should be_kind_of POI::Workbook | ||
end | ||
end | ||
|
||
it "should write an open workbook" do | ||
name = TestDataFile.expand_path("simple_with_picture.xlsx") | ||
POI::Workbook.open(name) do |book| | ||
lambda { book.save }.should_not raise_exception | ||
end | ||
end | ||
|
||
it "should write an open workbook to a new file" do | ||
pending "write to a temp directory to avoid git polution" do | ||
name = TestDataFile.expand_path("simple_with_picture.xlsx") | ||
new_name = TestDataFile.expand_path("saved-as.xlsx") | ||
|
||
POI::Workbook.open(name) do |book| | ||
lambda { book.save_as(new_name) }.should_not raise_exception | ||
end | ||
|
||
book = nil | ||
lambda { book = POI::Workbook.open(new_name) }.should_not raise_exception | ||
book.should be_kind_of POI::Workbook | ||
|
||
File.exists?(new_name).should == true | ||
end | ||
end | ||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'poi')) | ||
|
||
class TestDataFile | ||
def self.expand_path(name) | ||
File.expand_path(File.join(File.dirname(__FILE__), 'data', name)) | ||
end | ||
end | ||
|
||
Spec::Runner.configure do |config| | ||
end |
Oops, something went wrong.