excel-rb-appscript 0.0.7 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/README.md +24 -8
- data/excel-rb-appscript.gemspec +6 -6
- data/lib/Excel/worksheet.rb +16 -0
- metadata +6 -6
data/README.md
CHANGED
@@ -17,28 +17,44 @@ Because of the lack of documentations on how to use Ruby - Apple Script on Excel
|
|
17
17
|
Excel::App.open(path_of_file)
|
18
18
|
This will start the Excel and open the file
|
19
19
|
Return the workbook name which it opened
|
20
|
-
|
20
|
+
|
21
21
|
Excel::App.close
|
22
|
-
Close the file and shut down Excel
|
23
|
-
|
22
|
+
Close the file and shut down Excel without saving
|
23
|
+
|
24
24
|
Excel::App.workbooks
|
25
25
|
Return an array of all the opened workbooks
|
26
|
-
|
26
|
+
|
27
|
+
Excel::App.workbooks_paths
|
28
|
+
Return an array of all the paths for opened workbooks
|
29
|
+
|
27
30
|
Excel::App.workbook(workbook_name)
|
28
31
|
Return the Workbook object
|
29
|
-
|
32
|
+
|
33
|
+
Excel::App.save_all
|
34
|
+
Save all opened workbook
|
35
|
+
|
30
36
|
### Workbook
|
31
37
|
|
32
38
|
Excel::App.workbook("workbook.xls").worksheets
|
33
39
|
Return all the worksheets in workbook "workbook.xls"
|
34
|
-
|
40
|
+
|
35
41
|
Excel::App.workbook("workbook.xls").worksheet(worksheet_name)
|
36
42
|
Return the Worksheet object
|
37
43
|
|
44
|
+
Excel::App.workbook("workbook.xls").close
|
45
|
+
Close "workbook.xls" without saving
|
46
|
+
|
47
|
+
Excel::App.workbook("workbook.xls").save
|
48
|
+
Save "workbook.xls"
|
49
|
+
|
38
50
|
### Worksheet
|
39
51
|
|
40
52
|
Excel::App.workbook("workbook.xls").worksheet("sheet1").get_cell_value(cell_name)
|
41
53
|
e.g. cell_name: "A1" will return the value of cell "A1" in "sheet1"
|
42
|
-
|
54
|
+
|
43
55
|
Excel::App.workbook("workbook.xls").worksheet("sheet1").set_cell_value(cell_name, "Hello")
|
44
|
-
e.g. cell_name: "A1" will update the value of cell "A1" in "sheet1" to "Hello"
|
56
|
+
e.g. cell_name: "A1" will update the value of cell "A1" in "sheet1" to "Hello"
|
57
|
+
|
58
|
+
Excel::App.workbook("workbook.xls").worksheet("sheet1").get_values_in_range(from_cell, to_cell)
|
59
|
+
e.g. from_cell "A1", to_cell "B2", it will return a hash like this
|
60
|
+
{ A: { 1 => "hello", 2 => "world" }, B: { 1 => "lifes", 2 => "awesome" } }
|
data/excel-rb-appscript.gemspec
CHANGED
@@ -11,10 +11,10 @@ Gem::Specification.new do |gem|
|
|
11
11
|
# gem.executables = gem.files.grep(%r{^bin/}).map{ |f| File.basename(f) }
|
12
12
|
gem.name = "excel-rb-appscript"
|
13
13
|
gem.require_paths = ["lib"]
|
14
|
-
gem.version = "0.0.
|
15
|
-
|
16
|
-
|
17
|
-
gem.add_runtime_dependency "rb-appscript"
|
18
|
-
|
19
|
-
|
14
|
+
gem.version = "0.0.8"
|
15
|
+
|
16
|
+
|
17
|
+
gem.add_runtime_dependency "rb-appscript", '0.6.1'
|
18
|
+
|
19
|
+
|
20
20
|
end
|
data/lib/Excel/worksheet.rb
CHANGED
@@ -16,5 +16,21 @@ module Excel
|
|
16
16
|
def self.get_cell_value(cell)
|
17
17
|
@workbook.app_object.workbooks[@workbook.workbook_name].worksheets[@worksheet_name].cells[cell].value.get
|
18
18
|
end
|
19
|
+
|
20
|
+
def self.get_values_in_range(from, to)
|
21
|
+
from = from.match(/^([a-zA-Z]+)([0-9]+)$/)
|
22
|
+
from = {column: from[1], row: from[2].to_i}
|
23
|
+
|
24
|
+
to = to.match(/^([a-zA-Z]+)([0-9]+)$/)
|
25
|
+
to = {column: to[1], row: to[2].to_i}
|
26
|
+
|
27
|
+
return_hash = Hash.new{|h,k| h[k] = Hash.new}
|
28
|
+
(from[:column]..to[:column]).each do |column|
|
29
|
+
(from[:row]..to[:row]).each do |row|
|
30
|
+
return_hash[column][row] = get_cell_value("#{column}#{row}")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
return_hash
|
34
|
+
end
|
19
35
|
end
|
20
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: excel-rb-appscript
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,24 +9,24 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rb-appscript
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
|
-
- -
|
19
|
+
- - '='
|
20
20
|
- !ruby/object:Gem::Version
|
21
|
-
version:
|
21
|
+
version: 0.6.1
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
24
|
version_requirements: !ruby/object:Gem::Requirement
|
25
25
|
none: false
|
26
26
|
requirements:
|
27
|
-
- -
|
27
|
+
- - '='
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
version:
|
29
|
+
version: 0.6.1
|
30
30
|
description: simplified rb-appscript for excel
|
31
31
|
email:
|
32
32
|
- peter.wu@xbridge.com
|