trail_excel 1.0.1

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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: bfa73a84180cce01bc6ec19283ff7824a7f24969
4
+ data.tar.gz: e18f5c9786023068d70c35f19a5df544fb126016
5
+ SHA512:
6
+ metadata.gz: 5a87d081f53a368abd52ab4b6886a3d14b4db882f3e6a5b95dd56b4a04bd3cf5dfeda20ba340111cf4612ed9644c8d4532d090dd320e0f8c0ba6bafbae460417
7
+ data.tar.gz: dca51352b10f39c4cfa06010c635fe2312775cbd3b0a0b5f31b88101eea7d08ed11ba4f06a38b32c22a880da3eb5717c82265fae88be6beff66229470a398646
data/.gitignore ADDED
@@ -0,0 +1,9 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /Gemfile.lock
4
+ /_yardoc/
5
+ /coverage/
6
+ /doc/
7
+ /pkg/
8
+ /spec/reports/
9
+ /tmp/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in trail_excel.gemspec
4
+ gemspec
data/README.md ADDED
@@ -0,0 +1,32 @@
1
+ # TrailExcel
2
+
3
+ ## Installation
4
+
5
+ Add this line to your application's Gemfile:
6
+
7
+ ```ruby
8
+ gem 'trail_excel'
9
+ ```
10
+
11
+ And then execute:
12
+
13
+ $ bundle
14
+
15
+ Or install it yourself as:
16
+
17
+ $ gem install trail_excel
18
+
19
+ ## Usage
20
+
21
+ "http://www.trail4you.com/TechNote/Ruby/Trail_Selenium.doc/Worksheet.html"
22
+
23
+ ## Development
24
+
25
+ After checking out the repo, run `bin/setup` to install dependencies. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
26
+
27
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
28
+
29
+ ## Contributing
30
+
31
+ Bug reports and pull requests are welcome on GitHub at https://github.com/MtTrail/trail_excel.
32
+
data/Rakefile ADDED
@@ -0,0 +1,2 @@
1
+ require "bundler/gem_tasks"
2
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "trail_excel"
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require "pry"
11
+ # Pry.start
12
+
13
+ require "irb"
14
+ IRB.start
data/bin/setup ADDED
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,282 @@
1
+ #! ruby -EWindows-31J
2
+ # -*- mode:ruby; coding: Windows-31J -*-
3
+
4
+ require "trail_excel/version"
5
+
6
+
7
+
8
+ require 'win32ole'
9
+
10
+
11
+ ##----- Excel module -------------------------------
12
+
13
+ #Authors:: Mt.Trail
14
+ #Version:: 1.0 2016/7/17 Mt.Trail
15
+ #Copyright:: Copyrigth (C) Mt.Trail 2016 All rights reserved.
16
+ #License:: GPL version 2
17
+
18
+ #= Excel ���p�̂��߂̊g�����W���[��
19
+ #==�ړI
20
+ # ole32�𗘗p����Excel�𑀍삷��B
21
+ #
22
+
23
+ module Worksheet
24
+
25
+ #=== �Z���Q��
26
+ # sheet[y,x]
27
+ #
28
+ def [] y,x
29
+ cell = self.Cells.Item(y,x)
30
+ if cell.MergeCells
31
+ cell.MergeArea.Item(1,1).Value
32
+ else
33
+ cell.Value
34
+ end
35
+ end
36
+
37
+ #=== �Z�����
38
+ # sheet[y,x] = xx
39
+ #
40
+ def []= y,x,value
41
+ cell = self.Cells.Item(y,x)
42
+ if cell.MergeCells
43
+ cell.MergeArea.Item(1,1).Value = value
44
+ else
45
+ cell.Value = value
46
+ end
47
+ end
48
+
49
+ #=== �Z���̔w�i�F �Q��
50
+ # sheet.color(y,x)
51
+ #
52
+ def color(y,x)
53
+ self.Cells.Item(y,x).interior.colorindex
54
+ end
55
+
56
+ #=== �Z���̔w�i�F �ݒ�
57
+ # sheet.color(y,x,color)
58
+ #
59
+ def set_color(y,x,color)
60
+ self.Cells.Item(y,x).interior.colorindex = color
61
+ end
62
+
63
+ #=== �Z���͈̔͂ւ̔w�i�F �ݒ�
64
+ # set_range_color(y1,x1,y2,x2,color)
65
+ #
66
+ def set_range_color(y1,x1,y2,x2,color)
67
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
68
+ self.Range(r).interior.colorindex = color
69
+ end
70
+
71
+ #=== �Z���̕����F �Q��
72
+ # sheet.font_color(y,x)
73
+ #
74
+ def font_color(y,x)
75
+ self.Cells.Item(y,x).Font.colorindex
76
+ end
77
+
78
+ #=== �Z���̕����F �ݒ�
79
+ # sheet.set_font_color(y,x,color)
80
+ #
81
+ def set_font_color(y,x,color)
82
+ self.Cells.Item(y,x).Font.colorindex = color
83
+ end
84
+
85
+ #=== �Z���͈̔͂ւ̔w�i�F �ݒ�
86
+ # set_range_font_color(y1,x1,y2,x2,color)
87
+ #
88
+ def set_range_font_color(y1,x1,y2,x2,color)
89
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
90
+ self.Range(r).Font.colorindex = color
91
+ end
92
+
93
+ #=== �J�������ݒ�
94
+ #
95
+ def set_width(y,x,width)
96
+ self.Cells.Item(y,x).ColumnWidth = width
97
+ end
98
+
99
+ #=== �s�̍����ݒ�
100
+ #
101
+ def set_height(y,x,height)
102
+ self.Cells.Item(y,x).RowHeight = height
103
+ end
104
+
105
+
106
+ #=== �Z���ʒu���w�肷�镶����쐬
107
+ #
108
+ def r_str(y,x)
109
+ self.Cells.Item(y,x).address('RowAbsolute'=>false,'ColumnAbsolute'=>false)
110
+ end
111
+
112
+ #=== �Z����I��
113
+ #
114
+ def select( y,x)
115
+ r = r_str(y,x)
116
+ self.Range(r).select
117
+ end
118
+
119
+ #=== �Z���Ɏ���ݒ�
120
+ #
121
+ def formula( y,x,f)
122
+ r = r_str(y,x)
123
+ self.Range(r).Formula = f
124
+ end
125
+
126
+ #=== �Z���ɐݒ肳�ꂽ�����Q��
127
+ #
128
+ def get_formula( y,x)
129
+ r = r_str(y,x)
130
+ self.Range(r).Formula
131
+ end
132
+
133
+ #=== �s�̃O���[�v��
134
+ #
135
+ def group_row(y1,y2)
136
+ r = r_str(y1,1)+':'+r_str(y2,1)
137
+ self.Range(r).Rows.Group
138
+ end
139
+
140
+ #=== �J�����̃O���[�v��
141
+ #
142
+ def group_column(x1,x2)
143
+ r = r_str(1,x1)+':'+r_str(1,x2)
144
+ self.Range(r).Columns.Group
145
+ end
146
+
147
+ #=== �w��͈͂��}�[�W
148
+ #
149
+ def merge(y1,x1,y2,x2)
150
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
151
+ self.Range(r).MergeCells = true
152
+ end
153
+
154
+ #=== �g����ݒ�
155
+ #
156
+ def box(y1,x1,y2,x2)
157
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
158
+ self.Range(r).Borders.LineStyle = 1
159
+ end
160
+
161
+ #=== ������̐܂�Ԃ��w��
162
+ #
163
+ def wrap(y1,x1,y2,x2)
164
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
165
+ self.Range(r).HorizontalAlignment = 1
166
+ self.Range(r).WrapText = true
167
+ end
168
+
169
+ #=== ��t��
170
+ #
171
+ def v_top(y1,x1,y2,x2)
172
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
173
+ self.Range(r).VerticalAlignment = -4160
174
+ end
175
+
176
+ #=== ��������
177
+ #
178
+ def center(y1,x1,y2,x2)
179
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
180
+ self.Range(r).HorizontalAlignment = -4108
181
+ end
182
+
183
+ #=== �͈͎w��̎��̃R�s�[
184
+ #
185
+ def format_copy(y1,x1,y2,x2,y3,x3)
186
+ r2 = r_str(y3,x3)
187
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
188
+ self.Range(r2).Copy
189
+ self.Range(r).PasteSpecial('Paste' => -4122)
190
+ end
191
+
192
+ #=== �Z���̎��̃R�s�[
193
+ #
194
+ def format_copy1(y1,x1,y2,x2)
195
+ r2 = r_str(y2,x2)
196
+ r = r_str(y1,x1)
197
+ self.Range(r2).Copy
198
+ self.Range(r).PasteSpecial('Paste' => -4122)
199
+ end
200
+
201
+ #=== �R�s�[
202
+ #
203
+ def copy(y1,x1,y2,x2,y3,x3)
204
+ r2 = r_str(y3,x3)
205
+ r = r_str(y1,x1)+':'+r_str(y2,x2)
206
+ self.Range(r2).Copy
207
+ self.Range(r).PasteSpecial('Paste' => -4104)
208
+ end
209
+
210
+ #=== �s�̑}��
211
+ #
212
+ def insert_row(n)
213
+ self.Rows("#{n}:#{n}").Insert('Shift' => -4121)
214
+ end
215
+
216
+ #=== �s�̍폜
217
+ #
218
+ def delete_row(n,m)
219
+ self.Range("#{n}:#{m}").Delete
220
+ end
221
+
222
+ #=== �摜�̓\��t���@point�ʒu�w��
223
+ #
224
+ def add_picture(py,px,file,sh,sw)
225
+ self.Shapes.AddPicture(file,false,true,px,py,0.75*sw,0.75*sh)
226
+ end
227
+
228
+ #=== �摜�̓\��t���@�Z���ʒu�w��
229
+ #
230
+ def add_picture_at_cell(cy,cx,file,sh,sw)
231
+ r = self.Range(r_str(cy,cx))
232
+ self.Shapes.AddPicture(file,false,true,r.Left,r.Top,0.75*sw,0.75*sh)
233
+ end
234
+
235
+ end
236
+
237
+ ##----- End of Excel module -------------------------------
238
+
239
+ #=== ��΃p�X��
240
+ #
241
+ def getAbsolutePath filename
242
+ fso = WIN32OLE.new('Scripting.FileSystemObject')
243
+ fn = fso.GetAbsolutePathName(filename).gsub('\\','/')
244
+ fn
245
+ end
246
+
247
+ #=== Excel�̃I�[�v��
248
+ #
249
+ def openExcelWorkbook (filename, visible:false, pw:nil)
250
+ filename = getAbsolutePath(filename)
251
+ xl = WIN32OLE.new('Excel.Application')
252
+ xl.Visible = visible
253
+ xl.DisplayAlerts = true
254
+ if pw
255
+ book = xl.Workbooks.Open(:FileName=>"#{filename}",:Password=>pw)
256
+ else
257
+ book = xl.Workbooks.Open(filename)
258
+ end
259
+
260
+ begin
261
+ yield book
262
+ ensure
263
+ xl.Workbooks.Close
264
+ xl.Quit
265
+ end
266
+ end
267
+
268
+ #=== Excel�̃u�b�N����
269
+ #
270
+ def createExcelWorkbook
271
+ xl = WIN32OLE.new('Excel.Application')
272
+ xl.Visible = false
273
+ xl.DisplayAlerts = false
274
+ book = xl.Workbooks.Add()
275
+ begin
276
+ yield book
277
+ ensure
278
+ xl.Workbooks.Close
279
+ xl.Quit
280
+ end
281
+ end
282
+
@@ -0,0 +1,3 @@
1
+ module TrailExcel
2
+ VERSION = "1.0.1"
3
+ end
@@ -0,0 +1,23 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'trail_excel/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "trail_excel"
8
+ spec.version = TrailExcel::VERSION
9
+ spec.authors = ["Mt.Trail"]
10
+ spec.email = ["trail@trail4you.com"]
11
+
12
+ spec.summary = %q{Control EXCEL from ruby script}
13
+ spec.description = %q{Control EXCEL from ruby script}
14
+ spec.homepage = "http://www.trail4you.com/TechNote/Ruby/Trail_Selenium.doc/Worksheet.html"
15
+
16
+ spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
17
+ spec.bindir = "exe"
18
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_development_dependency "bundler", "~> 1.12"
22
+ spec.add_development_dependency "rake", "~> 10.0"
23
+ end
metadata ADDED
@@ -0,0 +1,81 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: trail_excel
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Mt.Trail
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2016-07-26 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.12'
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.12'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '10.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '10.0'
41
+ description: Control EXCEL from ruby script
42
+ email:
43
+ - trail@trail4you.com
44
+ executables: []
45
+ extensions: []
46
+ extra_rdoc_files: []
47
+ files:
48
+ - ".gitignore"
49
+ - Gemfile
50
+ - README.md
51
+ - Rakefile
52
+ - bin/console
53
+ - bin/setup
54
+ - lib/trail_excel.rb
55
+ - lib/trail_excel/version.rb
56
+ - trail_excel.gemspec
57
+ homepage: http://www.trail4you.com/TechNote/Ruby/Trail_Selenium.doc/Worksheet.html
58
+ licenses: []
59
+ metadata: {}
60
+ post_install_message:
61
+ rdoc_options: []
62
+ require_paths:
63
+ - lib
64
+ required_ruby_version: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ required_rubygems_version: !ruby/object:Gem::Requirement
70
+ requirements:
71
+ - - ">="
72
+ - !ruby/object:Gem::Version
73
+ version: '0'
74
+ requirements: []
75
+ rubyforge_project:
76
+ rubygems_version: 2.4.5.1
77
+ signing_key:
78
+ specification_version: 4
79
+ summary: Control EXCEL from ruby script
80
+ test_files: []
81
+ has_rdoc: