kameeoze / jruby-poi Goto Github PK
View Code? Open in Web Editor NEWJRuby library for working with Apache POI
License: Apache License 2.0
JRuby library for working with Apache POI
License: Apache License 2.0
Can't running rspec with jruby-poi.
$ ruby --version
jruby 1.6.5.1 (ruby-1.8.7-p330) (2011-12-27 1bf37c2) (Java HotSpot(TM) 64-Bit Server VM 1.7.0_04-ea) [darwin-amd64-java]
$ cat Gemfile
source 'http://rubygems.org'
gem 'jruby-poi'
gem 'rspec'
$ cat foo_spec.rb
require 'rubygems'
require 'rspec'
describe "test"
$ bundle update
$ bundle exec rspec foo_spec.rb
SystemStackError: stack level too deep
call at org/jruby/RubyProc.java:270
(root) at /Users/kazuhisa/.rvm/gems/jruby-1.6.5.1/gems/jruby-poi-0.8.2/bin/rspec:16
load at org/jruby/RubyKernel.java:1063
(root) at /Users/kazuhisa/.rvm/gems/jruby-1.6.5.1/gems/jruby-poi-0.8.2/bin/rspec:16
load at org/jruby/RubyKernel.java:1063
.
.
.
.
.
(root) at /Users/kazuhisa/.rvm/gems/jruby-1.6.5.1/gems/jruby-poi-0.8.2/bin/rspec:16
load at org/jruby/RubyKernel.java:1063
(root) at /Users/kazuhisa/.rvm/gems/jruby-1.6.5.1/gems/jruby-poi-0.8.2/bin/rspec:16
load at org/jruby/RubyKernel.java:1063
How should this problem be avoided?
Seems the version 0.9.0 has been very dated and needs to be upgraded to the current master version which is compitable with jruby9k.
Currently the poi libraries are 2 years old.
If you have an Excel file (I was using excel 2010 xlsx format) in which you have a column A that each cell in it is (for example) the sum of the next two cells in column B and C.
If you use jruby-poi to open said file and add values to column B and C on new row (where the value of A was 0 because the formula was there but C and B were empty), then you save the file and open it on Microsoft Excel the value on the new row's A will still be zero despite the fact that B and C are filled.
If you just click on the formula the value will update and you can't even undo back in to the original state. This had let me to conclude that it was formula cache.
I've used a workaround to this issue on code I used jruby-poi to edit a rather big file with a lot of formulas:
%w[jobs defects].each do |sheet_name|
sheet = self.workbook.worksheets[ sheet_name ]
rows = sheet.rows
from, to = 2, 70
rows.each_with_index do |row, i|
next if i <= from
#order is important!
%w[L K D E F N O P Q U V X Y Z W AA AB AC AD AE AF AG AH AI AJ].each do |letter|
column = letter.to_number - 1
puts sprintf( 'updating formulas on C: %s row %d', letter, i )
self.workbook.on_formula_update rows[ i ][ column ]
end
break if i >= to
end
end
Maybe there could be something like setForceFormulaRecalculation as it's described in http://poi.apache.org/spreadsheet/eval.html , maybe there already is, but the gem documentation could use some improvements.
I browsed thru the code and found some references to creating/setting styles.
But - I can't find any examples of how to use this. I'd like to know what options to pass to set and clear borders, font weights, and background colors.
Are there any examples that show how to do this??
thanks, Andy
Failed build here:
https://travis-ci.org/kameeoze/jruby-poi/jobs/3665930
Running locally against jruby-1.7.0 yields similar results.
Running locally against jruby-1.6.8 yields success.
NoMethodError: undefined method
row' for #Java::OrgApachePoiXssfUsermodel::XSSFSheet:0x7f92d2df- US Clients List.xlsm
[] at C:/downloads/jruby-9.1.0.0/lib/ruby/gems/shared/gems/jruby-poi-0.9.0/lib/poi/workbook/row.rb:12
[] at C:/downloads/jruby-9.1.0.0/lib/ruby/gems/shared/gems/jruby-poi-0.9.0/lib/poi/workbook/worksheet.rb:61
block in initialize at C:/downloads/jruby-9.1.0.0/lib/ruby/gems/shared/gems/orca_file_adapters-0.1.0/lib/orca/file_adapters/us_master_list.rb:41
mktmpdir at C:/downloads/jruby-9.1.0.0/lib/ruby/stdlib/tmpdir.rb:89`
jruby 9.1.0.0 (2.3.0) 2016-05-02 a633c63 Java HotSpot(TM) 64-Bit Server VM 24.71-b01 on 1.7.0_71-b14 +jit [mswin32-x86_64]
This may be a windows only problem. A quick test on my mac at home was unable to re-create....
The version hosted on rubygems is still 0.8.2, which fails with JRuby 1.6.7.2 in 1.9 mode.
If you create an excel spreadsheet (xls) from the following csv:
date,name, Sun Dec 31 13:59:59 CET 2006,Boogie
Then load it with jruby-poi, and access the cell with the date, you will get a Date with "2006-12-31"
The problematic code is here:
https://github.com/kameeoze/jruby-poi/blob/master/lib/poi/workbook/cell.rb#L168
Changing Date.parse to Time.parse seems like a safe bet.
Error opening file in Microsoft Office (Windows) file corrupted message.
The following changes using the gem 'jruby-poi'.
controller. rb
def relatorio_candidatos
if params [: candidate]
respond_to do | format |
{format.xls send_data Class.file_name (params [: class] [: object])
: filename => "file_name.xls"
: type => "application / xls"}
end
end
end
model. rb
require 'poi'
self.method def (object)
candidates Candidato.includes = ([{: person => {: cidade_nascimento =>: state}}: polo: titles,: primeira_opcao,: processo_seletivo]).
where ("= can.id?", object).
all
workbook = POI: Workbook.Open ("# {Rails.root} / lib / file_name.xls")
workbook.worksheets sheet = ["Sheets"]
rows = sheet.rows
...
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.