Skip to content

Commit b897898

Browse files
Merge pull request #10 from masood-anwer/master
Aspose.Cells Java for Ruby
2 parents cb63fa7 + 30897bc commit b897898

30 files changed

+1444
-0
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
source 'https://rubygems.org'
2+
3+
gemspec
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2001-2015 Aspose Pty Ltd
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
# Aspose_Cells_Java_For_Ruby
2+
Aspose Cells Java for Ruby is a gem that demonstrates / provides the Aspose.Cells for Java API usage examples in Ruby by using Rjb - Ruby Java Bridge.
3+
4+
## Installation
5+
6+
Add this line to your application's Gemfile:
7+
8+
```ruby
9+
gem 'asposecellsjava'
10+
```
11+
12+
And then execute:
13+
14+
$ bundle
15+
16+
Or install it yourself as:
17+
18+
$ gem install asposecellsjava
19+
20+
To download Aspose.Cells for Java API to be used with these examples through RJB, Please navigate to:
21+
22+
http://www.aspose.com/community/files/72/java-components/aspose.cells-for-java/
23+
24+
For most complete documentation of the project, check Aspose.Cells Java for Ruby confluence wiki link:
25+
26+
http://www.aspose.com/docs/display/cellssjava/3.+Aspose.Cells+Java+For+Ruby
27+
28+
## Usage
29+
30+
```ruby
31+
require '../lib/asposecellsjava'
32+
include Asposecellsjava
33+
include Asposecellsjava::HideUnhideWorksheet
34+
initialize_aspose_cells
35+
```
36+
Lets understand the above code
37+
* The first line makes sure that the aspose cells is loaded and available
38+
* Include the files that are required to access the aspose cells
39+
* Initialize the libraries. The aspose JAVA classes are loaded from the path provided in the aspose.yml file
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
require "bundler/gem_tasks"
2+
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# coding: utf-8
2+
lib = File.expand_path('../lib', __FILE__)
3+
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4+
require 'asposecellsjava/version'
5+
6+
Gem::Specification.new do |spec|
7+
spec.name = 'asposecellsjava'
8+
spec.version = Asposecellsjava::VERSION
9+
spec.authors = ['Aspose Marketplace']
10+
spec.email = ['[email protected]']
11+
spec.summary = %q{A Ruby gem to work with aspose.cells libraries}
12+
spec.description = %q{AsposeCellsJava is a Ruby gem that can help working with Aspose.Cells libraries}
13+
spec.homepage = 'https://github.com/asposecells/Aspose_Cells_Java/tree/master/Plugins/Aspose_Cells_Java_for_Ruby'
14+
spec.license = 'MIT'
15+
16+
spec.files = `git ls-files`.split($/)
17+
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18+
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19+
spec.require_paths = ['lib']
20+
21+
spec.add_development_dependency 'bundler', '~> 1.7'
22+
spec.add_development_dependency 'rake', '~> 10.0'
23+
spec.add_development_dependency 'rspec'
24+
25+
spec.add_dependency 'rjb', '~> 1.5.2'
26+
27+
end
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
jar_dir: ../asposecellsjava/jars
2+
license_path: ../asposecellsjava/license/path
3+
jvm_args: -Xms512m -Xmx1G
4+
5+
23 KB
Binary file not shown.
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<html>
2+
<head>
3+
<title>Sample "Hello, World" Application</title>
4+
</head>
5+
<body bgcolor=white>
6+
7+
<table border="0" cellpadding="10">
8+
<tr>
9+
<td>
10+
<img src="images/springsource.png">
11+
</td>
12+
<td>
13+
<h1>Sample "Hello, World" Application</h1>
14+
</td>
15+
</tr>
16+
</table>
17+
18+
<p>This is the home page for the HelloWorld Web application. </p>
19+
<p>To prove that they work, you can execute either of the following links:
20+
<ul>
21+
<li>To a <a href="hello.jsp">JSP page</a>.
22+
<li>To a <a href="hello">servlet</a>.
23+
</ul>
24+
25+
</body>
26+
</html>
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
require_relative 'asposecellsjava/version'
2+
require_relative 'asposecellsjava/asposecells'
3+
require 'logger'
4+
require 'rjb'
5+
6+
module Asposecellsjava
7+
8+
class << self
9+
attr_accessor :aspose_cells_config
10+
end
11+
12+
def initialize_aspose_cells
13+
aspose_jars_dir = Asposecellsjava.aspose_cells_config ? Asposecellsjava.aspose_cells_config['jar_dir'] : nil
14+
aspose_license_path = Asposecellsjava.aspose_cells_config ? Asposecellsjava.aspose_cells_config['license_path'] : nil
15+
jvm_args = Asposecellsjava.aspose_cells_config ? Asposecellsjava.aspose_cells_config['jvm_args'] : nil
16+
17+
load_aspose_jars(aspose_jars_dir, jvm_args)
18+
load_aspose_license(aspose_license_path)
19+
end
20+
21+
def load_aspose_license(aspose_license_path)
22+
if aspose_license_path && File.exist?(aspose_license_path)
23+
set_license(File.join(aspose_license_path))
24+
else
25+
logger = Logger.new(STDOUT)
26+
logger.level = Logger::WARN
27+
logger.warn('Using the non licensed aspose jar. Please specify path to your aspose license directory in config/aspose.yml file!')
28+
end
29+
end
30+
31+
def load_aspose_jars(aspose_jars_dir, jvm_args)
32+
if aspose_jars_dir && File.exist?(aspose_jars_dir)
33+
jardir = File.join(aspose_jars_dir, '**', '*.jar')
34+
else
35+
jardir = File.join(File.dirname(File.dirname(__FILE__)), 'jars', '**', '*.jar')
36+
end
37+
38+
if jvm_args
39+
args = jvm_args.split(' ') << '-Djava.awt.headless=true'
40+
logger = Logger.new(STDOUT)
41+
logger.level = Logger::DEBUG
42+
logger.debug("JVM args : #{args}")
43+
Rjb::load(classpath = Dir.glob(jardir).join(':'), jvmargs=args)
44+
else
45+
Rjb::load(classpath = Dir.glob(jardir).join(':'), jvmargs=['-Djava.awt.headless=true'])
46+
end
47+
48+
end
49+
50+
def input_file(file)
51+
Rjb::import('java.io.FileInputStream').new(file)
52+
end
53+
54+
def set_license(aspose_license_file)
55+
begin
56+
fstream = input_file(aspose_license_file)
57+
license = Rjb::import('com.aspose.api.License').new()
58+
license.setLicense(fstream)
59+
rescue Exception => ex
60+
logger = Logger.new(STDOUT)
61+
logger.level = Logger::ERROR
62+
logger.error("Could not load the license file : #{ex}")
63+
fstream.close() if fstream
64+
end
65+
end
66+
67+
def self.configure_aspose_cells config
68+
Asposecellsjava.aspose_cells_config = config
69+
end
70+
71+
end
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
require_relative 'hideunhideworksheet'
2+
require_relative 'displayhidetabs'
3+
require_relative 'displayhidescrollbars'
4+
require_relative 'displayhidegridlines'
5+
require_relative 'displayhiderowcolumnheaders'
6+
require_relative 'pagebreakpreview'
7+
require_relative 'zoomfactor'
8+
require_relative 'freezepanes'
9+
require_relative 'splitpanes'
10+
require_relative 'managingworksheets'
11+
require_relative 'pagebreaks'
12+
require_relative 'copyworksheets'
13+
require_relative 'converter'
14+
require_relative 'encrypt'
15+
require_relative 'document'
16+
require_relative 'rowsandcolumns'
17+
require_relative 'protection'
18+
require_relative 'pagesetup'

0 commit comments

Comments
 (0)