aio_elin 1.1.1 → 1.1.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 5add890da1f929e9fdf9b6975d2361ee53e19323b09e329e7ffda3875f0ba5c3
4
- data.tar.gz: e8bbaa676e2ff53db21f720f43f4a05d43329ea758c3d9b2a4b1db296ffb5f36
3
+ metadata.gz: d8fbf9239592da86bb45f4e1bb27c1c02eb78e022d7b2c48ec12a4fa0d7b0b5b
4
+ data.tar.gz: e1392795fbbceb6e78a0377fd351580d5060368f03ef28ddec92c3240144087a
5
5
  SHA512:
6
- metadata.gz: 323842c51f98dbeb9819828e102f614bb38f8722d92a8a1b9f87d9a1846fdd9733b13c470b8485c57fc79802e7fbafd920ffb1d82b4deceac094c43fbe460a36
7
- data.tar.gz: ff67ddef33a8641c8b2c716f9c5550f5eee64d45372a018ab874eec9c8748e479254b3382d006a4213141e213176aa37cec952cf23c08abecbb94507dd593ad0
6
+ metadata.gz: 5f5ef05ea08e1708a9c60ee76c844203c4c2df56fb2df4632bf1eac70d06e925a534000e249075c9091305d2131b065219f14a7c3cd090ba7d169a680626b5cb
7
+ data.tar.gz: dacc8f95e9cf190a18cd1eebbb2e8b686d6ece7e5c21fa44e2ddc45d249c30077c1e004f0e6b8500938612d431feeb666f17a1e01a8c7355361bd42ec7a128dc
@@ -1,438 +1,437 @@
1
1
  module Aio::Base::Toolkit
2
- module ExcelWps
3
- class WorkBook
4
-
5
- include Aio::Ui::Verbose
6
-
7
- @@worksheets_name = []
8
- def initialize(encoding = "utf-8")
9
-
10
- if Aio::Base::Toolkit::OS.windows?
11
- require "win32ole"
12
- else
13
- debugger
14
- print_error "只有Windows系统才能使用Excel模块"
15
- exit 0
16
- end
17
-
18
-
19
- @excel = WIN32OLE.new("excel.Application")
20
- @excel.visible = false
21
- @workbook = @excel.workbooks.add
22
- @encoding = encoding
23
- create_style
24
- end
25
-
26
- # 警告提示开关
27
- def display_alerts=(bool)
28
- @excel.DisplayAlerts = bool
29
- end
30
-
31
- def add_worksheet(name)
32
- while @@worksheets_name.include?(name)
33
- name += "1"
34
- end
35
- @@worksheets_name << name
36
- worksheet = @workbook.worksheets.add
37
- worksheet.activate
38
-
39
- # 在同一进程中多次打开会出现name的问题, 所以干脆全部使用sheet
40
- # worksheet.name = name
41
- worksheet.name = "sheet"
42
- return WorkSheet.new(worksheet)
43
- end
44
-
45
- def create_style
46
- sty = @workbook.styles.add("NormalStyle")
47
- self.class.normal_style(sty)
48
-
49
- sty = @workbook.styles.add("BoldStyle")
50
- self.class.bold_style(sty)
51
-
52
- sty = @workbook.styles.add("TitleStyle")
53
- self.class.title_style(sty)
54
- end
55
-
56
- def self.normal_style(sty)
57
- sty.font.size = 9
58
- sty.borders(7).linestyle = 1
59
- sty.borders(8).linestyle = 1
60
- sty.borders(9).linestyle = 1
61
- sty.borders(10).linestyle = 1
62
- sty.HorizontalAlignment = -4108
63
- end
64
-
65
- def self.bold_style(sty)
66
- sty.font.size = 9
67
- sty.font.bold = true
68
- sty.borders(7).linestyle = 1
69
- sty.borders(8).linestyle = 1
70
- sty.borders(9).linestyle = 1
71
- sty.borders(10).linestyle = 1
72
- sty.HorizontalAlignment = -4108
73
- end
74
-
75
- def self.title_style(sty)
76
- sty.font.size = 20
77
- sty.font.bold = true
78
- sty.borders(7).linestyle = 1
79
- sty.borders(8).linestyle = 1
80
- sty.borders(9).linestyle = 1
81
- sty.borders(10).linestyle = 1
82
- sty.HorizontalAlignment = -4108
83
- end
84
-
85
- def show
86
- @excel.visible = true
87
- end
88
-
89
- def save(path)
90
- @workbook.saveas(path)
91
- end
92
-
93
- def close
94
- @workbook.close
95
- @excel.quit
96
- end
97
- end # class WorkBook
98
-
99
- class WorkSheet
100
- IMAGE_ROW_NUM = 56
101
- @@worksheets_name = []
102
- def initialize(worksheet)
103
- @row_count = 1
104
- @worksheet = worksheet
105
- @nil_space = []
106
- end
107
-
108
- # 增加一个空行
109
- def add_space_line(n=1)
110
- return if n < 1
111
- @row_count += n
112
- end
113
-
114
- # 对列进行合并
115
- def merge(range1, range2)
116
- @worksheet.range("#{range1}:#{range2}").merge
117
- end
118
-
119
- # 产生 ::Range 类
120
- def range(str)
121
- @worksheet.range(str)
122
- end
123
-
124
- # 添加标题行
125
- def add_title(name)
126
- add_row.add_cell(name, false, "BoldStyle")
127
- end
128
-
129
- # 设置列的宽度
130
- def width(col, width)
131
- @worksheet.Columns("#{col}:#{col}").ColumnWidth = width
132
- end
133
-
134
- def height(height)
135
- @row_height = height
136
- end
137
-
138
- # 增加Row类
139
- def add_row(&block)
140
- @current_row = Row.new(@worksheet, @row_count)
141
- @current_row.height = @row_height if @row_height
142
- @row_count += 1
143
- yield @current_row if block
144
- return @current_row
145
- end
146
-
147
- # 返回此时的Row类
148
- def current_row
149
- return @current_row
150
- end
151
-
152
- # 返回此时的行索引
153
- def current_row_id
154
- return @current_row.row_id
155
- end
156
-
157
- # 添加图像
158
- def add_image(image_path)
159
- return unless File.exist?(image_path)
160
- add_space_line
161
- add_row
162
- cell_name = current_row.first_cell
163
- @worksheet.Range(cell_name).Select
164
- @worksheet.Pictures.Insert(image_path)
165
- add_space_line IMAGE_ROW_NUM
166
- end
167
-
168
- # 判断是否有垂直分页符存在
169
- def has_pagebreak?
170
- @worksheet.VPageBreaks.count > 0
171
- end
172
-
173
- # 对列修改分页符
174
- def pagebreak(col)
175
- @worksheet.VPageBreaks(1).Location = @worksheet.columns(col)
176
- end
177
-
178
- # 返回::WorkSheet
179
- def worksheet
180
- @worksheet
181
- end
182
-
183
- # 添加图表
184
- def add_chart(&block)
185
- ch = @worksheet.Shapes.AddChart
186
- active = ch.chart
187
-
188
- # 占位符
189
- block.call(Chart.new(active))
190
-
191
- ch.copy
192
- end
193
- end # SheetWork Class
194
-
195
- class Row
196
- FILL_TYPE = 4
197
-
198
- attr_reader :row_id
199
-
200
- @@cell_map = ("A".."Z").to_a
201
- def initialize(worksheet, row_id)
202
- @row_id = row_id
203
- @cell_count = 0
204
- @worksheet = worksheet
205
- @nil_space = []
206
- end
207
-
208
- # 此时的单元格
209
- def curent_cell
210
- return cell_name(@cell_count)
211
- end
212
-
213
- # 第一个单元格
214
- def first_cell
215
- return cell_name(0)
216
- end
217
-
218
- # 设置行高
219
- def height=(height)
220
- @worksheet.rows(@row_id).RowHeight = height
221
- end
222
-
223
- # 增加单元格
224
- def add_cell(value, auto_fit = false, style = "NormalStyle")
225
- range = @worksheet.Range(cell_name(@cell_count))
226
- range.Value = value.to_s
227
- range.Style = style
228
- range.Columns.AutoFit if auto_fit
229
- @cell_count += 1
230
- while(@nil_space.include?(to_letter(@cell_count))) do
231
- range = @worksheet.Range(cell_name(@cell_count))
232
- range.Value = ""
233
- range.Style = style
234
- @cell_count += 1
235
- end
236
-
237
- end
238
-
239
- # 通过索引变成对应的字母
240
- def to_letter(index)
241
- @@cell_map.at(index)
242
- end
243
-
244
- # 特别注意,由于Toolkit中加入了Array,String的模块
245
- # 所以判断的时候特别注意要是
246
- def << (arr)
247
- case arr
248
- when ::Array
249
- arr.size.times do |t|
250
- add_cell(arr[t])
251
- end
252
- when ::String
253
- add_cell(arr)
254
- end
255
- end
256
-
257
- # 获得单元格的名字(通过索引)
258
- def cell_name(index)
259
- second = index % 26
260
- first = (index - second) / 26
261
- if first == 0
262
- return @@cell_map[second] + @row_id.to_s
263
- end
264
- first -= 1
265
- return @@cell_map[first] + @@cell_map[second] + @row_id.to_s
266
- end
267
-
268
- # 获得单元格的名字(通过字母)
269
- def cell_name!(letter)
270
- return letter + @row_id.to_s
271
- end
272
-
273
- def set_cell(index, value, auto_fit = false, style = "NormalStyle")
274
- range = @worksheet.Range(cell_name(index))
275
- range.Value = value.to_s
276
- range.Style = style
277
- range.Columns.AutoFit if auto_fit
278
- end
279
-
280
- # 设置单元格风格
281
- def set_style(letter, style = "NormalStyle")
282
- range = @worksheet.range(cell_name!(letter))
283
- range.Style = style
284
- end
285
-
286
- # 合并一行中的单元格
287
- def merge(idx_begin, idx_end)
288
- cell_begin = "#{idx_begin}#{@row_id}"
289
- cell_end = "#{idx_end}#{@row_id}"
290
- range = @worksheet.Range("#{cell_begin}:#{cell_end}")
291
- range.merge
292
- tmp = ((idx_begin.upcase)..(idx_end.upcase)).to_a
293
- tmp.shift
294
- @nil_space = (@nil_space | tmp).sort
295
- end
296
-
297
- # 开启自动换行
298
- def wraptext(letter)
299
- range = @worksheet.range(cell_name!(letter))
300
- range.WrapText = true
301
- end
302
-
303
- # 对此时的行的下方下分页符
304
- def pagebreak
305
- @worksheet.rows(@row_id+1).PageBreak = 1
306
- end
307
-
308
- # 返回此时的::Row类
309
- def real_row
310
- @worksheet.rows(@row_id)
311
- end
312
-
313
- alias :style :set_style
314
- end
315
-
316
- # 图表
317
- class Chart
318
-
319
- # 图形类型
320
- ColumnClustered = 51 # 簇状柱形图
321
- ColumnStacked = 52 # 堆积柱状图
322
- Doughnut = -4120 # 圆环图
323
- Line = 4 # 折线图
324
- Pie = 5 # 饼图
325
- BarClustered = 57 # 簇状条形图
326
-
327
- # 标签数据
328
- DataLabelsShowLabel = 4 # 数据点所属的分类
329
- DataLabelsShowLabelAndPercent = 5 # 占比百分比以及所属分类,仅饼图
330
- DataLabelsShowPercent = 3 # 百分比, 仅饼图
331
- DataLabelsShowValue = 2 # 默认值
332
-
333
-
334
- def initialize(active)
335
- @chart = active
336
- end
337
-
338
- def chart_work
339
- @chart
340
- end
341
-
342
- # 标签选项
343
- def now_table
344
- #@chart.SeriesCollection(n).DataLabels
345
- num = @chart.SeriesCollection.Count
346
- num.times do |t|
347
- t += 1
348
- yield @chart.SeriesCollection(t).DataLabels
349
- end
350
- end
351
-
352
- # 修改标题
353
- def title=(name)
354
- @chart.HasTitle = true
355
- @chart.ChartTitle.Characters.Text = name
356
- end
357
-
358
- # 这是原数据地址, 以每列数据作为一个系列
359
- def source=(range)
360
- @chart.SetSourceData(range, 2)
361
- end
362
-
363
- # 更改图形类型
364
- def type=(c_type)
365
- @chart.ChartType = c_type
366
- end
367
-
368
- # 设置X轴名称, 只用于条形图
369
- def axes_x=(name)
370
- @chart.Axes(1,1).HasTitle = true
371
- @chart.Axes(1,1).AxisTitle.Characters.Text = name
372
- end
373
-
374
- # 设置Y轴名称, 只用于条形图
375
- def axes_y=(name)
376
- @chart.Axes(2,1).HasTitle = true
377
- @chart.Axes(2,1).AxisTitle.Characters.Text = name
378
- end
379
-
380
- # 设置坐标轴格式, 刻度单位
381
- def axes_unit(int)
382
- @chart.Axes(2).MajorUnit = int
383
- @chart.Axes(2).MinorUnit = int
384
- end
385
-
386
- # 修改样式
387
- # 通过录制宏可以查看样式编号
388
- # 条形图中203 比较好看
389
- # 饼图中 251, 254 比较好看
390
- def style=(int)
391
- @chart.ChartStyle = int
392
- data_label
393
- end
394
-
395
- # 添加饼图的百分比
396
- def data_label(type=DataLabelsShowLabelAndPercent)
397
-
398
- # 应用标签选项
399
- @chart.ApplyDataLabels(type)
400
-
401
- # 取消标签选项的系列名称
402
- now = @chart.SeriesCollection(1).DataLabels
403
- now.ShowSeriesName = false
404
-
405
- # 将图例放到右边
406
- now = @chart.Legend
407
- now.Position = -4152
408
- end
409
-
410
- # 标签系列名称开关
411
- def series_name=(bool)
412
- now_table do |n|
413
- n.ShowSeriesName = bool
414
- end
415
- end
416
-
417
- # 标签类别名称开关
418
- def category_name=(bool)
419
- now_table do |n|
420
- n.ShowCategoryName = bool
421
- end
422
- end
423
-
424
- # 标签值开关
425
- def value=(bool)
426
- now_table do |n|
427
- n.ShowValue = bool
428
- n.ShowLegendKey = 0 unless bool
429
- n.Separator = " " unless bool
430
- end
431
- end
432
-
433
- end
434
-
435
- end
2
+ module ExcelWps
3
+ class WorkBook
4
+
5
+ include Aio::Ui::Verbose
6
+
7
+ @@worksheets_name = []
8
+ def initialize(encoding = "utf-8")
9
+
10
+ if Aio::Base::Toolkit::OS.windows?
11
+ require "win32ole"
12
+ else
13
+ print_error "只有Windows系统才能使用Excel模块"
14
+ exit 0
15
+ end
16
+
17
+
18
+ @excel = WIN32OLE.new("excel.Application")
19
+ @excel.visible = false
20
+ @workbook = @excel.workbooks.add
21
+ @encoding = encoding
22
+ create_style
23
+ end
24
+
25
+ # 警告提示开关
26
+ def display_alerts=(bool)
27
+ @excel.DisplayAlerts = bool
28
+ end
29
+
30
+ def add_worksheet(name)
31
+ while @@worksheets_name.include?(name)
32
+ name += "1"
33
+ end
34
+ @@worksheets_name << name
35
+ worksheet = @workbook.worksheets.add
36
+ worksheet.activate
37
+
38
+ # 在同一进程中多次打开会出现name的问题, 所以干脆全部使用sheet
39
+ # worksheet.name = name
40
+ worksheet.name = "sheet"
41
+ return WorkSheet.new(worksheet)
42
+ end
43
+
44
+ def create_style
45
+ sty = @workbook.styles.add("NormalStyle")
46
+ self.class.normal_style(sty)
47
+
48
+ sty = @workbook.styles.add("BoldStyle")
49
+ self.class.bold_style(sty)
50
+
51
+ sty = @workbook.styles.add("TitleStyle")
52
+ self.class.title_style(sty)
53
+ end
54
+
55
+ def self.normal_style(sty)
56
+ sty.font.size = 9
57
+ sty.borders(7).linestyle = 1
58
+ sty.borders(8).linestyle = 1
59
+ sty.borders(9).linestyle = 1
60
+ sty.borders(10).linestyle = 1
61
+ sty.HorizontalAlignment = -4108
62
+ end
63
+
64
+ def self.bold_style(sty)
65
+ sty.font.size = 9
66
+ sty.font.bold = true
67
+ sty.borders(7).linestyle = 1
68
+ sty.borders(8).linestyle = 1
69
+ sty.borders(9).linestyle = 1
70
+ sty.borders(10).linestyle = 1
71
+ sty.HorizontalAlignment = -4108
72
+ end
73
+
74
+ def self.title_style(sty)
75
+ sty.font.size = 20
76
+ sty.font.bold = true
77
+ sty.borders(7).linestyle = 1
78
+ sty.borders(8).linestyle = 1
79
+ sty.borders(9).linestyle = 1
80
+ sty.borders(10).linestyle = 1
81
+ sty.HorizontalAlignment = -4108
82
+ end
83
+
84
+ def show
85
+ @excel.visible = true
86
+ end
87
+
88
+ def save(path)
89
+ @workbook.saveas(path)
90
+ end
91
+
92
+ def close
93
+ @workbook.close
94
+ @excel.quit
95
+ end
96
+ end # class WorkBook
97
+
98
+ class WorkSheet
99
+ IMAGE_ROW_NUM = 56
100
+ @@worksheets_name = []
101
+ def initialize(worksheet)
102
+ @row_count = 1
103
+ @worksheet = worksheet
104
+ @nil_space = []
105
+ end
106
+
107
+ # 增加一个空行
108
+ def add_space_line(n=1)
109
+ return if n < 1
110
+ @row_count += n
111
+ end
112
+
113
+ # 对列进行合并
114
+ def merge(range1, range2)
115
+ @worksheet.range("#{range1}:#{range2}").merge
116
+ end
117
+
118
+ # 产生 ::Range 类
119
+ def range(str)
120
+ @worksheet.range(str)
121
+ end
122
+
123
+ # 添加标题行
124
+ def add_title(name)
125
+ add_row.add_cell(name, false, "BoldStyle")
126
+ end
127
+
128
+ # 设置列的宽度
129
+ def width(col, width)
130
+ @worksheet.Columns("#{col}:#{col}").ColumnWidth = width
131
+ end
132
+
133
+ def height(height)
134
+ @row_height = height
135
+ end
136
+
137
+ # 增加Row类
138
+ def add_row(&block)
139
+ @current_row = Row.new(@worksheet, @row_count)
140
+ @current_row.height = @row_height if @row_height
141
+ @row_count += 1
142
+ yield @current_row if block
143
+ return @current_row
144
+ end
145
+
146
+ # 返回此时的Row类
147
+ def current_row
148
+ return @current_row
149
+ end
150
+
151
+ # 返回此时的行索引
152
+ def current_row_id
153
+ return @current_row.row_id
154
+ end
155
+
156
+ # 添加图像
157
+ def add_image(image_path)
158
+ return unless File.exist?(image_path)
159
+ add_space_line
160
+ add_row
161
+ cell_name = current_row.first_cell
162
+ @worksheet.Range(cell_name).Select
163
+ @worksheet.Pictures.Insert(image_path)
164
+ add_space_line IMAGE_ROW_NUM
165
+ end
166
+
167
+ # 判断是否有垂直分页符存在
168
+ def has_pagebreak?
169
+ @worksheet.VPageBreaks.count > 0
170
+ end
171
+
172
+ # 对列修改分页符
173
+ def pagebreak(col)
174
+ @worksheet.VPageBreaks(1).Location = @worksheet.columns(col)
175
+ end
176
+
177
+ # 返回::WorkSheet
178
+ def worksheet
179
+ @worksheet
180
+ end
181
+
182
+ # 添加图表
183
+ def add_chart(&block)
184
+ ch = @worksheet.Shapes.AddChart
185
+ active = ch.chart
186
+
187
+ # 占位符
188
+ block.call(Chart.new(active))
189
+
190
+ ch.copy
191
+ end
192
+ end # SheetWork Class
193
+
194
+ class Row
195
+ FILL_TYPE = 4
196
+
197
+ attr_reader :row_id
198
+
199
+ @@cell_map = ("A".."Z").to_a
200
+ def initialize(worksheet, row_id)
201
+ @row_id = row_id
202
+ @cell_count = 0
203
+ @worksheet = worksheet
204
+ @nil_space = []
205
+ end
206
+
207
+ # 此时的单元格
208
+ def curent_cell
209
+ return cell_name(@cell_count)
210
+ end
211
+
212
+ # 第一个单元格
213
+ def first_cell
214
+ return cell_name(0)
215
+ end
216
+
217
+ # 设置行高
218
+ def height=(height)
219
+ @worksheet.rows(@row_id).RowHeight = height
220
+ end
221
+
222
+ # 增加单元格
223
+ def add_cell(value, auto_fit = false, style = "NormalStyle")
224
+ range = @worksheet.Range(cell_name(@cell_count))
225
+ range.Value = value.to_s
226
+ range.Style = style
227
+ range.Columns.AutoFit if auto_fit
228
+ @cell_count += 1
229
+ while(@nil_space.include?(to_letter(@cell_count))) do
230
+ range = @worksheet.Range(cell_name(@cell_count))
231
+ range.Value = ""
232
+ range.Style = style
233
+ @cell_count += 1
234
+ end
235
+
236
+ end
237
+
238
+ # 通过索引变成对应的字母
239
+ def to_letter(index)
240
+ @@cell_map.at(index)
241
+ end
242
+
243
+ # 特别注意,由于Toolkit中加入了Array,String的模块
244
+ # 所以判断的时候特别注意要是
245
+ def <<(arr)
246
+ case arr
247
+ when ::Array
248
+ arr.size.times do |t|
249
+ add_cell(arr[t])
250
+ end
251
+ when ::String
252
+ add_cell(arr)
253
+ end
254
+ end
255
+
256
+ # 获得单元格的名字(通过索引)
257
+ def cell_name(index)
258
+ second = index % 26
259
+ first = (index - second) / 26
260
+ if first == 0
261
+ return @@cell_map[second] + @row_id.to_s
262
+ end
263
+ first -= 1
264
+ return @@cell_map[first] + @@cell_map[second] + @row_id.to_s
265
+ end
266
+
267
+ # 获得单元格的名字(通过字母)
268
+ def cell_name!(letter)
269
+ return letter + @row_id.to_s
270
+ end
271
+
272
+ def set_cell(index, value, auto_fit = false, style = "NormalStyle")
273
+ range = @worksheet.Range(cell_name(index))
274
+ range.Value = value.to_s
275
+ range.Style = style
276
+ range.Columns.AutoFit if auto_fit
277
+ end
278
+
279
+ # 设置单元格风格
280
+ def set_style(letter, style = "NormalStyle")
281
+ range = @worksheet.range(cell_name!(letter))
282
+ range.Style = style
283
+ end
284
+
285
+ # 合并一行中的单元格
286
+ def merge(idx_begin, idx_end)
287
+ cell_begin = "#{idx_begin}#{@row_id}"
288
+ cell_end = "#{idx_end}#{@row_id}"
289
+ range = @worksheet.Range("#{cell_begin}:#{cell_end}")
290
+ range.merge
291
+ tmp = ((idx_begin.upcase)..(idx_end.upcase)).to_a
292
+ tmp.shift
293
+ @nil_space = (@nil_space | tmp).sort
294
+ end
295
+
296
+ # 开启自动换行
297
+ def wraptext(letter)
298
+ range = @worksheet.range(cell_name!(letter))
299
+ range.WrapText = true
300
+ end
301
+
302
+ # 对此时的行的下方下分页符
303
+ def pagebreak
304
+ @worksheet.rows(@row_id+1).PageBreak = 1
305
+ end
306
+
307
+ # 返回此时的::Row类
308
+ def real_row
309
+ @worksheet.rows(@row_id)
310
+ end
311
+
312
+ alias :style :set_style
313
+ end
314
+
315
+ # 图表
316
+ class Chart
317
+
318
+ # 图形类型
319
+ ColumnClustered = 51 # 簇状柱形图
320
+ ColumnStacked = 52 # 堆积柱状图
321
+ Doughnut = -4120 # 圆环图
322
+ Line = 4 # 折线图
323
+ Pie = 5 # 饼图
324
+ BarClustered = 57 # 簇状条形图
325
+
326
+ # 标签数据
327
+ DataLabelsShowLabel = 4 # 数据点所属的分类
328
+ DataLabelsShowLabelAndPercent = 5 # 占比百分比以及所属分类,仅饼图
329
+ DataLabelsShowPercent = 3 # 百分比, 仅饼图
330
+ DataLabelsShowValue = 2 # 默认值
331
+
332
+
333
+ def initialize(active)
334
+ @chart = active
335
+ end
336
+
337
+ def chart_work
338
+ @chart
339
+ end
340
+
341
+ # 标签选项
342
+ def now_table
343
+ #@chart.SeriesCollection(n).DataLabels
344
+ num = @chart.SeriesCollection.Count
345
+ num.times do |t|
346
+ t += 1
347
+ yield @chart.SeriesCollection(t).DataLabels
348
+ end
349
+ end
350
+
351
+ # 修改标题
352
+ def title=(name)
353
+ @chart.HasTitle = true
354
+ @chart.ChartTitle.Characters.Text = name
355
+ end
356
+
357
+ # 这是原数据地址, 以每列数据作为一个系列
358
+ def source=(range)
359
+ @chart.SetSourceData(range, 2)
360
+ end
361
+
362
+ # 更改图形类型
363
+ def type=(c_type)
364
+ @chart.ChartType = c_type
365
+ end
366
+
367
+ # 设置X轴名称, 只用于条形图
368
+ def axes_x=(name)
369
+ @chart.Axes(1,1).HasTitle = true
370
+ @chart.Axes(1,1).AxisTitle.Characters.Text = name
371
+ end
372
+
373
+ # 设置Y轴名称, 只用于条形图
374
+ def axes_y=(name)
375
+ @chart.Axes(2,1).HasTitle = true
376
+ @chart.Axes(2,1).AxisTitle.Characters.Text = name
377
+ end
378
+
379
+ # 设置坐标轴格式, 刻度单位
380
+ def axes_unit(int)
381
+ @chart.Axes(2).MajorUnit = int
382
+ @chart.Axes(2).MinorUnit = int
383
+ end
384
+
385
+ # 修改样式
386
+ # 通过录制宏可以查看样式编号
387
+ # 条形图中203 比较好看
388
+ # 饼图中 251, 254 比较好看
389
+ def style=(int)
390
+ @chart.ChartStyle = int
391
+ data_label
392
+ end
393
+
394
+ # 添加饼图的百分比
395
+ def data_label(type=DataLabelsShowLabelAndPercent)
396
+
397
+ # 应用标签选项
398
+ @chart.ApplyDataLabels(type)
399
+
400
+ # 取消标签选项的系列名称
401
+ now = @chart.SeriesCollection(1).DataLabels
402
+ now.ShowSeriesName = false
403
+
404
+ # 将图例放到右边
405
+ now = @chart.Legend
406
+ now.Position = -4152
407
+ end
408
+
409
+ # 标签系列名称开关
410
+ def series_name=(bool)
411
+ now_table do |n|
412
+ n.ShowSeriesName = bool
413
+ end
414
+ end
415
+
416
+ # 标签类别名称开关
417
+ def category_name=(bool)
418
+ now_table do |n|
419
+ n.ShowCategoryName = bool
420
+ end
421
+ end
422
+
423
+ # 标签值开关
424
+ def value=(bool)
425
+ now_table do |n|
426
+ n.ShowValue = bool
427
+ n.ShowLegendKey = 0 unless bool
428
+ n.Separator = " " unless bool
429
+ end
430
+ end
431
+
432
+ end
433
+
434
+ end
436
435
  end
437
436
 
438
-
437
+
@@ -23,7 +23,6 @@ class Aio::Module::Cmd::Cisco::ShowEnv < Aio::Module::Cmd::Cisco
23
23
 
24
24
  def parse
25
25
  cont = self.context.dup
26
- debugger
27
26
 
28
27
  # 是有版本区别的,要分开对待
29
28
  case device_template
@@ -72,7 +71,6 @@ class Aio::Module::Cmd::Cisco::ShowEnv < Aio::Module::Cmd::Cisco
72
71
  end
73
72
 
74
73
  def parse_tmp_2(cont)
75
- debugger
76
74
  useful[:fan] = {}
77
75
  cont.readline_match_block(/Main Power Supply is AC/) {|b|b}
78
76
  cont.readline_match_block(reg_blank) {|b|b}
@@ -18,7 +18,6 @@ class Aio::Module::Cmd::H3C::DisplayMemory < Aio::Module::Cmd::H3C
18
18
  end
19
19
 
20
20
  def parse
21
- debugger
22
21
  cont = self.context.dup
23
22
  #memory = {}
24
23
  #useful[:memory] = memory
@@ -16,7 +16,6 @@ class Aio::Module::OutputStyle::CompareDiff < Aio::Module::OutputStyle
16
16
  end
17
17
 
18
18
  def generate
19
- debugger
20
19
  device_manager
21
20
  end
22
21
  end
@@ -35,7 +35,6 @@ class Aio::Module::SpecialStyle::CompareOld < Aio::Module::SpecialStyle
35
35
 
36
36
  end
37
37
 
38
- debugger
39
38
  clear_line
40
39
  clear_other_info(device_warning, input_benchmark)
41
40
  delete(device_warning, input_benchmark)
@@ -142,7 +142,6 @@ class Aio::Module::SpecialStyle::CompareWithDeviceManager < Aio::Module::Special
142
142
  cm1_dup = cm1.dup
143
143
  cm2_dup = cm2.dup
144
144
 
145
- debugger
146
145
  # res 为相同的内容
147
146
  total = cm1.size
148
147
  cm1.each_with_index do |link_1, i|
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: aio_elin
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.1
4
+ version: 1.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Elin