excel-rb-appscript 0.0.0

Sign up to get free protection for your applications and to get access to all the features.
data/README ADDED
File without changes
@@ -0,0 +1,20 @@
1
+ # -*- encoding: utf-8 -*-
2
+
3
+ Gem::Specification.new do |gem|
4
+ gem.authors = ["Peter Wu"]
5
+ gem.email = ["peter.wu@xbridge.com"]
6
+ gem.description = %q{rb-appscript excel extension}
7
+ gem.summary = %q{with basic excel dictionary}
8
+ gem.homepage = ""
9
+
10
+ gem.files = `git ls-files`.split($\)
11
+ # gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
12
+ gem.name = "excel-rb-appscript"
13
+ gem.require_paths = ["lib"]
14
+ gem.version = "0.0.0"
15
+
16
+
17
+ gem.add_runtime_dependency "rb-appscript"
18
+
19
+
20
+ end
data/lib/Excel/app.rb ADDED
@@ -0,0 +1,44 @@
1
+ require 'appscript'
2
+
3
+ module Excel
4
+ class App
5
+ @file_path = ""
6
+ @current_worksheet = nil
7
+
8
+ # attr_accessor :trades_hash
9
+ @app_object = Appscript.app("Microsoft Excel")
10
+ @work_book = nil
11
+ @work_sheet = nil
12
+
13
+ def self.app_object
14
+ @app_object
15
+ end
16
+
17
+ def self.open(params)
18
+ file_path = MacTypes::Alias.path(params[:path])
19
+ app_object.run
20
+ app_object.activate
21
+
22
+ app_object.open file_path
23
+
24
+ File.basename(file_path.path)
25
+ end
26
+
27
+ def self.workbooks
28
+ app_object.workbooks.get.collect {|wb| wb.name.get }
29
+ end
30
+
31
+ def self.workbook wb
32
+ # raise "Workbook not found" if !(workbooks.include? wb)
33
+ WorkBook.new(self, wb)
34
+ end
35
+
36
+ def self.close
37
+ app_object.run
38
+ app_object.activate
39
+ app_object.workbooks.saved.set(true)
40
+ app_object.workbooks.close
41
+ app_object.quit
42
+ end
43
+ end
44
+ end
@@ -0,0 +1,29 @@
1
+ module Excel
2
+ class WorkBook
3
+ @app_object = nil
4
+ @workbook_name = nil
5
+
6
+ def self.new(app, wb_name)
7
+ @app_object = app
8
+ @workbook_name = wb_name
9
+ self
10
+ end
11
+
12
+ def self.workbook_name
13
+ @workbook_name
14
+ end
15
+
16
+ def self.app_object
17
+ @app_object.app_object
18
+ end
19
+
20
+ def self.worksheets
21
+ app_object.workbooks[workbook_name].worksheets.get.collect {|ws| ws.name.get }
22
+ end
23
+
24
+ def self.worksheet ws
25
+ # raise "Worksheet not found" if !(worksheets.include? ws)
26
+ WorkSheet.new(self, ws)
27
+ end
28
+ end
29
+ end
@@ -0,0 +1,20 @@
1
+ module Excel
2
+ class WorkSheet
3
+ @worksheet_name = nil
4
+ @workbook = nil
5
+
6
+ def self.new(wb, ws_name)
7
+ @workbook = wb
8
+ @worksheet_name = ws_name
9
+ self
10
+ end
11
+
12
+ def self.set_cell_value(cell, value)
13
+ @workbook.app_object.set(@workbook.app_object.workbooks[@workbook.workbook_name].worksheets[@worksheet_name].cells[cell].value, {:to => value})
14
+ end
15
+
16
+ def self.get_cell_value(cell)
17
+ @workbook.app_object.workbooks[@workbook.workbook_name].worksheets[@worksheet_name].cells[cell].value.get
18
+ end
19
+ end
20
+ end
@@ -0,0 +1,5 @@
1
+ require 'excel/app'
2
+ require 'excel/workbook'
3
+ require 'excel/worksheet'
4
+
5
+ include Excel
metadata ADDED
@@ -0,0 +1,67 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: excel-rb-appscript
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Peter Wu
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2012-06-18 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rb-appscript
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ! '>='
28
+ - !ruby/object:Gem::Version
29
+ version: '0'
30
+ description: rb-appscript excel extension
31
+ email:
32
+ - peter.wu@xbridge.com
33
+ executables: []
34
+ extensions: []
35
+ extra_rdoc_files: []
36
+ files:
37
+ - README
38
+ - excel-rb-appscript.gemspec
39
+ - lib/Excel/app.rb
40
+ - lib/Excel/workbook.rb
41
+ - lib/Excel/worksheet.rb
42
+ - lib/excel-rb-appscript.rb
43
+ homepage: ''
44
+ licenses: []
45
+ post_install_message:
46
+ rdoc_options: []
47
+ require_paths:
48
+ - lib
49
+ required_ruby_version: !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ required_rubygems_version: !ruby/object:Gem::Requirement
56
+ none: false
57
+ requirements:
58
+ - - ! '>='
59
+ - !ruby/object:Gem::Version
60
+ version: '0'
61
+ requirements: []
62
+ rubyforge_project:
63
+ rubygems_version: 1.8.21
64
+ signing_key:
65
+ specification_version: 3
66
+ summary: with basic excel dictionary
67
+ test_files: []