-
Notifications
You must be signed in to change notification settings - Fork 4
/
ns_egt_maker.py
1759 lines (1554 loc) · 100 KB
/
ns_egt_maker.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
'''
SPDX-License-Identifier: Apache-2.0
Copyright 2023 Cisco Systems, Inc. and its affiliates
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
'''
import sys, os
import openpyxl
from openpyxl.styles import Font, Border, Side, PatternFill
import tkinter as tk ,tkinter.ttk as ttk, tkinter.filedialog, tkinter.messagebox
from tkinter import *
import subprocess
import ns_def
'''
common variables
'''
##### Default Font #####
defalut_font = Font(name="Futura", size=11, color='FF000000') # default font
table_header_font = Font(name="Futura", bold=True, size=11, color='FFFFFFFF')
##### Font and style Settings for each bullet #####
first_paragraph_font = Font(name="Futura", bold=True, size=16, color='FF1f497d', )
first_paragraph_height = 20.25
first_paragraph_bullet_front = '['
first_paragraph_bullet_back = ']'
second_paragraph_font = Font(name="Futura", bold=True, underline='single', size=16, color='FF1f497d', )
second_paragraph_height = 20.25
second_paragraph_bullet_front = '⁃'
second_paragraph_bullet_back = ''
third_paragraph_font = Font(name="Futura", bold=True, underline='single', size=16, color='FF000000', )
third_paragraph_height = 20.25
third_paragraph_bullet_front = '•'
third_paragraph_bullet_back = ''
fourth_paragraph_font = Font(name="Futura", underline='single', size=16, color='FF000000', )
fourth_paragraph_height = 20.25
fourth_paragraph_bullet_front = '◦'
fourth_paragraph_bullet_back = ''
fifth_paragraph_font = Font(name="Futura", underline='single', size=16, color='FF000000', )
fifth_paragraph_height = 20.25
fifth_paragraph_bullet_front = '‣'
fifth_paragraph_bullet_back = ''
num_to_font = {1: first_paragraph_font, 2: second_paragraph_font, 3: third_paragraph_font, 4: fourth_paragraph_font, 5: fifth_paragraph_font}
num_to_height = {1: first_paragraph_height, 2: second_paragraph_height, 3: third_paragraph_height, 4: fourth_paragraph_height, 5: fifth_paragraph_height}
num_to_bullet_front = {1: first_paragraph_bullet_front, 2: second_paragraph_bullet_front, 3: third_paragraph_bullet_front, 4: fourth_paragraph_bullet_front, 5: fifth_paragraph_bullet_front}
num_to_bullet_back = {1: first_paragraph_bullet_back, 2: second_paragraph_bullet_back, 3: third_paragraph_bullet_back, 4: fourth_paragraph_bullet_back, 5: fifth_paragraph_bullet_back}
##### Enable or Disable mark #####
Enable_mark = '🗹'
Disable_mark = '☐'
##### type of bullet depend on usage type #####
bullet_direct_front = '>>'
bullet_direct_back = ''
bullet_select_front = '>'
bullet_select_back = ''
##### Excel Border Settings #####
white_border = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="FFFFFF"))
blue_border_start = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="000000"), # update for Network Sketcher Ver 2.0
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
blue_border_medium = Border(left=Side(border_style="thin", color="4f81bd"),
right=Side(border_style="thin", color="4f81bd"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
blue_border_end = Border(left=Side(border_style="thin", color="4f81bd"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
gray_blue_border_start = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="000000"), #Change Value for Network Sketcher ver 2.0
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
gray_blue_border_medium = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="dce6f1"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
gray_blue_border_end = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
gray_blue_border_start_updown_same = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="dce6f1"),
top=Side(border_style="thin", color="dce6f1"),
bottom=Side(border_style="thin", color="dce6f1"))
gray_blue_border_medium_updown_same = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="dce6f1"),
top=Side(border_style="thin", color="dce6f1"),
bottom=Side(border_style="thin", color="dce6f1"))
gray_blue_border_end_updown_same = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="dce6f1"),
bottom=Side(border_style="thin", color="dce6f1"))
gray_blue_border_start_bottom_same = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="dce6f1"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="dce6f1"))
gray_blue_border_medium_bottom_same = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="dce6f1"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="dce6f1"))
gray_blue_border_end_bottom_same = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="dce6f1"))
gray_blue_border_start_top_same = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="dce6f1"),
top=Side(border_style="thin", color="dce6f1"),
bottom=Side(border_style="thin", color="000000"))
gray_blue_border_medium_top_same = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="dce6f1"),
top=Side(border_style="thin", color="dce6f1"),
bottom=Side(border_style="thin", color="000000"))
gray_blue_border_end_top_same = Border(left=Side(border_style="thin", color="dce6f1"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="dce6f1"),
bottom=Side(border_style="thin", color="000000"))
black_border_start = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="000000"), # change valule from FFFFFF for Network Sketcher Ver2.0
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
black_border_medium = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
black_border_end = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="000000"))
black_border_start_updown_same = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="FFFFFF"))
black_border_medium_updown_same = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="FFFFFF"))
black_border_end_updown_same = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="FFFFFF"))
black_border_start_bottom_same = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="FFFFFF"))
black_border_medium_bottom_same = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="FFFFFF"))
black_border_end_bottom_same = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="FFFFFF"))
black_border_start_top_same = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="000000"), # change valule from FFFFFF for Network Sketcher Ver2.0
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="000000"))
black_border_medium_top_same = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="000000"))
black_border_end_top_same = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="000000"))
TOP_WHITE_border_start = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
# bottom=Side(border_style="thin", color="000000") #please keep '#'
)
TOP_WHITE_border_medium = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
# bottom=Side(border_style="thin", color="000000") #please keep '#'
)
TOP_WHITE_border_end = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="FFFFFF"),
# bottom=Side(border_style="thin", color="000000") #please keep '#'
)
BOTTOM_WHITE_border_start = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="FFFFFF"),
# top=Side(border_style="thin", color="000000"),
bottom=Side(border_style="thin", color="FFFFFF"))
BOTTOM_WHITE_border_medium = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
# top=Side(border_style="thin", color="000000"), #please keep '#'
bottom=Side(border_style="thin", color="FFFFFF"))
BOTTOM_WHITE_border_end = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="000000"),
# top=Side(border_style="thin", color="000000"), #please keep '#'
bottom=Side(border_style="thin", color="FFFFFF"))
BOTTOM_LAST_border_start = Border(left=Side(border_style="thin", color="000000"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="000000"))
BOTTOM_LAST_border_medium = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="FFFFFF"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="000000"))
BOTTOM_LAST_border_end = Border(left=Side(border_style="thin", color="FFFFFF"),
right=Side(border_style="thin", color="000000"),
top=Side(border_style="thin", color="FFFFFF"),
bottom=Side(border_style="thin", color="000000"))
##### cell color #####
blue_cell = PatternFill(patternType='solid', fgColor='4f81bd', bgColor='4f81bd')
white_cell = PatternFill(patternType='solid', fgColor='FFFFFF', bgColor='FFFFFF')
gray_blue_cell = PatternFill(patternType='solid', fgColor='dce6f1', bgColor='dce6f1')
'''
DEF get common variables
'''
def get_excel_cell_format(num_paragraph, type): # type--> font,height,bullet_front,bullet_back,Enable_mark,Disable_mark,direct_front,direct_back,select_front,select_back
num_to_font = {1: first_paragraph_font, 2: second_paragraph_font, 3: third_paragraph_font, 4: fourth_paragraph_font, 5: fifth_paragraph_font}
num_to_height = {1: first_paragraph_height, 2: second_paragraph_height, 3: third_paragraph_height, 4: fourth_paragraph_height, 5: fifth_paragraph_height}
num_to_bullet_front = {1: first_paragraph_bullet_front, 2: second_paragraph_bullet_front, 3: third_paragraph_bullet_front, 4: fourth_paragraph_bullet_front, 5: fifth_paragraph_bullet_front}
num_to_bullet_back = {1: first_paragraph_bullet_back, 2: second_paragraph_bullet_back, 3: third_paragraph_bullet_back, 4: fourth_paragraph_bullet_back, 5: fifth_paragraph_bullet_back}
if type == 'font':
return_value = num_to_font[num_paragraph]
elif type == 'height':
return_value = num_to_height[num_paragraph]
elif type =='bullet_front':
return_value = num_to_bullet_front[num_paragraph]
elif type == 'bullet_back':
return_value = num_to_bullet_back[num_paragraph]
elif type == 'Enable_mark':
return_value = Enable_mark
elif type == 'Disable_mark':
return_value = Disable_mark
elif type == 'direct_front':
return_value = bullet_direct_front
elif type == 'direct_back':
return_value = bullet_direct_back
elif type == 'select_front':
return_value = bullet_select_front
elif type == 'select_back':
return_value = bullet_select_back
return(return_value)
'''
CREATE EXCEL FILE with GUI TREE format
'''
def create_excel_gui_tree(input_excel_name,output_excel_name,NEW_OR_ADD,egt_maker_width_array): #Add egt_maker_width_array for Network Sketcher ver 2.0
##### User Settings #####
excel_file_end_count = 3 # Set the number of consecutive empty input_row in input excel file for detecting end.
limit_max_column = 5 # Set the max number of column each input_row for detecting column end.
size_of_column_width = 22 # Set the width value of column
size_of_row_height = 14.25 # Set the height value of row
format_number_of_column = 15 # format number of column. format border/width/height For Example, Column:A = 1 Column:AA = 27 Column:CZ = 104.
number_of_add_modify_rows = 10 # add number of coordinated empty rows under ended row.
add_empty_row_paragraph = True # If true, empty row is added under the paragraph
##### Default font and message #####
defalut_message_to_paragraph = 'N/A or Omitted because there is little necessity.' # add the message to under paragraph. '' is not used.
##### System Settings #####
empty_count = 0
empty_count_sub = 0
column = 1
input_row = 1
output_row = 1
number_of_sheets = 1
##### Main script prepared #####
input_tree_excel = openpyxl.load_workbook(input_excel_name)
#print('Read the input excel file -> ' + input_excel_name)
##### NEW Sheet , Insert paragraph##
if NEW_OR_ADD == 'ADD':
output_tree_excel = openpyxl.load_workbook(output_excel_name)
number_of_sheets += 1
elif NEW_OR_ADD == 'PARA':
number_of_add_modify_rows = -1
output_tree_excel = openpyxl.load_workbook(output_excel_name)
number_of_sheets += 1
output_row = int(input_tree_excel.active.cell(1, 1).value)+3
input_tree_excel.active.cell(1, 1).value = None
sheetNames = input_tree_excel.get_sheet_names()
output_tree_excel.active = output_tree_excel.sheetnames.index(sheetNames[0])
insert_excel_empty_row(output_tree_excel, sheetNames[0], output_row-1)
insert_excel_empty_row(output_tree_excel, sheetNames[0], output_row-1)
insert_excel_empty_row(output_tree_excel, sheetNames[0], output_row-1)
else:
output_tree_excel = openpyxl.Workbook()
##### Main script #####
while empty_count <= excel_file_end_count:
for column in range(1, limit_max_column + 1):
if column == 1 and input_tree_excel.active.cell(input_row, column).value != None:
### make a new sheet and set value###
if number_of_sheets == 1:
output_tree_excel.active.title = input_tree_excel.active.cell(input_row, column).value
output_tree_excel.active.cell(output_row, column).value = num_to_bullet_front[column] + input_tree_excel.active.cell(input_row, column).value + num_to_bullet_back[column]
number_of_sheets += 1
first_sheet_name = str(output_tree_excel.active.title)
#print('Create a new sheet -> ' + output_tree_excel.active.cell(output_row, column).value)
else:
output_row = 1
output_tree_excel.create_sheet(title=str(input_tree_excel.active.cell(input_row, column).value))
output_tree_excel.active = output_tree_excel[str(input_tree_excel.active.cell(input_row, column).value)]
output_tree_excel.active.cell(output_row, column).value = num_to_bullet_front[column] + input_tree_excel.active.cell(input_row, column).value + num_to_bullet_back[column]
number_of_sheets += 1
#print('Create a new sheet -> ' + output_tree_excel.active.cell(output_row, column).value)
output_tree_excel.active.row_dimensions[output_row].height = first_paragraph_height
output_tree_excel.active.cell(output_row, column).font = first_paragraph_font
empty_count = 0
### set value to more than second column###
elif input_tree_excel.active.cell(input_row, column).value != None:
output_tree_excel.active.cell(output_row, column).value = num_to_bullet_front[column] + input_tree_excel.active.cell(input_row, column).value + num_to_bullet_back[column]
print(' Add -> ' +input_tree_excel.active.cell(input_row, column).value)
empty_count = 0
### set font and height to more than second colum ###
output_tree_excel.active.row_dimensions[output_row].height = num_to_height[column]
output_tree_excel.active.cell(output_row, column).font = num_to_font[column]
### set defalut message to under the row ###
if defalut_message_to_paragraph != '':
output_row += 1
output_tree_excel.active.cell(output_row, column).value = defalut_message_to_paragraph
output_tree_excel.active.cell(output_row, column).font = defalut_font
for i in range(1, format_number_of_column + 1):
output_tree_excel.active.cell(output_row, output_tree_excel.active.cell(output_row, i).column).border = white_border
### set empty row to under the row ###
if add_empty_row_paragraph == True:
output_row += 1
for i in range(1, format_number_of_column + 1):
output_tree_excel.active.cell(output_row, output_tree_excel.active.cell(output_row, i).column).border = white_border
### If all of columns are None###
else:
empty_count_sub += 1
### check end of current sheet###
if empty_count_sub >= limit_max_column:
### add empty row with decided height###
for i in range(output_row + 1, output_row + number_of_add_modify_rows):
output_tree_excel.active.row_dimensions[i].height = size_of_row_height
### add empty row with white border###
for i in range(1, format_number_of_column + 1):
for k in range(output_row, output_row + number_of_add_modify_rows):
output_tree_excel.active.cell(k, output_tree_excel.active.cell(k, i).column).border = white_border
empty_count += 1
empty_count_sub = 0
### increment the input_row number until empty_count reatch the value###
input_row += 1
output_row += 1
### STEP1->change size of column and row. STEP2->make white border in row###
if NEW_OR_ADD != 'PARA': ### Safety function. If PARA, do not following scriput.
for i in range(1, format_number_of_column + 1):
output_tree_excel.active.column_dimensions[str(openpyxl.utils.get_column_letter(i))].width = size_of_column_width
#Add Customize width value function for Network Sketcher ver 2.0
if len(egt_maker_width_array) >= i:
output_tree_excel.active.column_dimensions[str(openpyxl.utils.get_column_letter(i))].width = egt_maker_width_array[i - 1]
for k in range(1, output_row):
output_tree_excel.active.cell(k, output_tree_excel.active.cell(k, i).column).border = white_border
### move to first sheet and save the file###
if NEW_OR_ADD == 'NEW':
output_tree_excel.active = output_tree_excel[first_sheet_name]
output_tree_excel.save(output_excel_name)
print('Complete to Save the output excel file -> ' + output_excel_name)
return(output_tree_excel)
'''
EXCEL DEF
'''
def write_excel_paragraph(input_tree_excel, worksheet_name ,start_row, start_column, input_msg, paragraph_level):
input_tree_excel.active = input_tree_excel[worksheet_name]
input_tree_excel.active.cell(start_row, start_column-1).value = None
input_tree_excel.active.cell(start_row, start_column).value = num_to_bullet_front[paragraph_level]+input_msg +num_to_bullet_back[paragraph_level]
input_tree_excel.active.row_dimensions[start_row].height = num_to_height[paragraph_level]
input_tree_excel.active.cell(start_row, start_column).font = num_to_font[paragraph_level]
return(input_tree_excel)
def write_excel_cell(input_excel, worksheet_name ,start_row, start_column, input_msg, input_num_column, cell_style, write_style):
input_excel.active = input_excel[worksheet_name]
#####Insert row, if write_style == INSERT. ######
if write_style == 'INSERT':
input_excel = insert_excel_empty_row(input_excel, worksheet_name, start_row)
#####write columns belong row ######
write_column = start_column
if input_msg == '<EMPTY>' or input_msg == '_EMPTY_': # Add <EMPTY> function for Network Sketcher ver 2.0
input_excel.active.cell(start_row, write_column).value = ''
else:
input_excel.active.cell(start_row, write_column).value = input_msg
if cell_style == 'TABLE_HEADER':
input_excel.active.cell(start_row, write_column).font = table_header_font
for c in range(write_column, write_column + input_num_column):
input_excel.active.cell(start_row, c).fill = blue_cell
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = blue_border_start
elif c == (write_column+input_num_column-1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = blue_border_end
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = blue_border_medium
write_column = write_column + input_num_column
elif cell_style == 'SUB_TITLE':
input_excel.active.cell(start_row, write_column).font = defalut_font
for c in range(write_column, write_column + input_num_column):
input_excel.active.cell(start_row, c).fill = gray_blue_cell
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_start
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_end
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_medium
if input_msg == None or input_msg == '':
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_start_updown_same
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_end_updown_same
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_medium_updown_same
### First or last normal table. Border is changed
if (input_msg != None or input_msg != '') and write_style == 'BOTTOM_SAME':
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_start_bottom_same
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_end_bottom_same
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_medium_bottom_same
if (input_msg != None or input_msg != '') and write_style == 'TOP_SAME':
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_start_top_same
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_end_top_same
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = gray_blue_border_medium_top_same
write_column = write_column + input_num_column
elif cell_style == 'TABLE_NORMAL':
input_excel.active.cell(start_row, write_column).font = defalut_font
for c in range(write_column, write_column + input_num_column):
#### Add TABLE_NORMAL cell color###
input_excel.active.cell(start_row, c).fill = white_cell
#### Add TABLE_NORMAL script###
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_start
elif c == (write_column+input_num_column-1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_end
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_medium
if input_msg == None or input_msg == '':
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_start_updown_same
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_end_updown_same
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_medium_updown_same
### First or last normal table. Border is changed
if (input_msg != None or input_msg != '') and write_style == 'BOTTOM_SAME':
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_start_bottom_same
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_end_bottom_same
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_medium_bottom_same
if write_style == 'TOP_SAME':
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_start_top_same
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_end_top_same
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_medium_top_same
if write_style == 'EDGE':
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_medium
elif c == (write_column + input_num_column - 1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_end
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_medium
write_column = write_column + input_num_column
elif cell_style == 'TABLE_TOP_WHITE':
input_excel.active.cell(start_row, write_column).font = defalut_font
for c in range(write_column, write_column + input_num_column):
input_excel.active.cell(start_row, c).fill = white_cell
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = TOP_WHITE_border_start
input_excel.active.cell(start_row-1, input_excel.active.cell(start_row, c).column).border = BOTTOM_WHITE_border_start
elif c == (write_column+input_num_column-1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = TOP_WHITE_border_end
input_excel.active.cell(start_row-1, input_excel.active.cell(start_row, c).column).border = BOTTOM_WHITE_border_end
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = TOP_WHITE_border_medium
input_excel.active.cell(start_row-1, input_excel.active.cell(start_row, c).column).border = BOTTOM_WHITE_border_medium
write_column = write_column + input_num_column
elif cell_style == 'TOP_LAST':
input_excel.active.cell(start_row, write_column).font = defalut_font
for c in range(write_column, write_column + input_num_column):
input_excel.active.cell(start_row, c).fill = white_cell
if c == start_column:
#input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = TOP_BLACK_border_medium
input_excel.active.cell(start_row - 1, input_excel.active.cell(start_row, c).column).border = BOTTOM_LAST_border_start
elif c == (write_column+input_num_column-1):
#input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = TOP_BLACK_border_medium
input_excel.active.cell(start_row - 1, input_excel.active.cell(start_row, c).column).border = BOTTOM_LAST_border_end
else:
#input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = TOP_BLACK_border_medium
input_excel.active.cell(start_row - 1, input_excel.active.cell(start_row, c).column).border = BOTTOM_LAST_border_medium
write_column = write_column + input_num_column
return (input_excel)
def write_excel_table(input_excel, worksheet_name ,start_row, start_column, dict_input_msg, dict_input_num_column, cell_style, write_style):
input_excel.active = input_excel[worksheet_name]
#####Insert row, if write_style == INSERT. For non vertical######
if write_style == 'INSERT' and '_Vertical' not in cell_style: #exclude vertical pattern
input_excel = insert_excel_empty_row(input_excel, worksheet_name, start_row)
#####write columns belong row ######
write_column = start_column
write_row = start_row
temp_flag_insert = False
d=0
while d < len(dict_input_msg):
if cell_style == 'TABLE_HEADER':
input_excel.active.cell(start_row, write_column).value = dict_input_msg[d]
input_excel.active.cell(start_row, write_column).font = table_header_font
for c in range(write_column, write_column + dict_input_num_column[d]):
input_excel.active.cell(start_row, c).fill = blue_cell
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = blue_border_start
elif c == (write_column+dict_input_num_column[d]-1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = blue_border_end
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = blue_border_medium
write_column = write_column + dict_input_num_column[d]
elif cell_style == 'TABLE_NORMAL':
input_excel.active.cell(start_row, write_column).value = dict_input_msg[d]
input_excel.active.cell(start_row, write_column).font = defalut_font
for c in range(write_column, write_column + dict_input_num_column[d]):
input_excel.active.cell(start_row, c).fill = white_cell
if c == start_column:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_start
elif c == (write_column+dict_input_num_column[d]-1):
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_end
else:
input_excel.active.cell(start_row, input_excel.active.cell(start_row, c).column).border = black_border_medium
write_column = write_column + dict_input_num_column[d]
elif cell_style == 'TABLE_HEADER_Vertical':
if write_style == 'INSERT' and temp_flag_insert != True:
for o in range(0,len(dict_input_msg)):
input_excel = insert_excel_empty_row(input_excel, worksheet_name, start_row)
temp_flag_insert = True
input_excel.active.cell(write_row, start_column).value = dict_input_msg[d]
input_excel.active.cell(write_row, start_column).font = defalut_font
for c in range(start_column , start_column + dict_input_num_column[0]):
input_excel.active.cell(write_row, c).fill = gray_blue_cell
if c == start_column:
input_excel.active.cell(write_row, input_excel.active.cell(write_row, c).column).border = gray_blue_border_start
elif c == (write_column+dict_input_num_column[0]-1):
input_excel.active.cell(write_row, input_excel.active.cell(write_row, c).column).border = gray_blue_border_end
else:
input_excel.active.cell(write_row, input_excel.active.cell(write_row, c).column).border = gray_blue_border_medium
write_row += 1
elif cell_style == 'TABLE_NORMAL_Vertical':
input_excel.active.cell(write_row, start_column).value = dict_input_msg[d]
input_excel.active.cell(write_row, start_column).font = defalut_font
for c in range(start_column, start_column + dict_input_num_column[0]):
input_excel.active.cell(write_row, c).fill = white_cell
if c == start_column:
input_excel.active.cell(write_row, input_excel.active.cell(write_row, c).column).border = black_border_start
elif c == (write_column + dict_input_num_column[0] - 1):
input_excel.active.cell(write_row, input_excel.active.cell(write_row, c).column).border = black_border_end
else:
input_excel.active.cell(write_row, input_excel.active.cell(write_row, c).column).border = black_border_medium
write_row += 1
d += 1
return (input_excel)
def insert_excel_empty_row(input_excel, worksheet_name, insert_row):
##### User Settings #####
format_number_of_column = 15 # format number of column. format border/width/height For Example, Column:A = 1 Column:AA = 27 Column:CZ = 104.
size_of_row_height = 14.25 #Set the height value of row
##### Excel Border Settings #####
white_border = Border(left=Side(border_style="thin",color="FFFFFF"),
right=Side(border_style="thin",color="FFFFFF"),
top=Side(border_style="thin",color="FFFFFF"),
bottom=Side(border_style="thin",color="FFFFFF"))
##### insert row and modify fond and height #####
input_excel.active = input_excel[worksheet_name]
get_under_row_height = input_excel.active.row_dimensions[insert_row+1].height
input_excel.active.insert_rows(insert_row)
input_excel.active.row_dimensions[insert_row+1].height = size_of_row_height
input_excel.active.row_dimensions[insert_row+2].height = get_under_row_height
for i in range(1, format_number_of_column+1):
input_excel.active.cell(insert_row, input_excel.active.cell(insert_row, i).column).border = white_border
return(input_excel)
def get_start_row_or_column(input_tree_excel_file,worksheet_name,paragraph_name, row_or_column):
##### user settings #####
max_number_of_serch_colmun = 5000
##### system settings #####
temp_found_flag = False
temp_row = 1
temp_column = 1
##### Open the input excel file #####
input_tree_excel = openpyxl.load_workbook(input_tree_excel_file)
input_tree_excel.active = input_tree_excel[worksheet_name]
##### Search locaton of the paragraph name #####
while temp_row <= max_number_of_serch_colmun and temp_found_flag == False:
for temp_column in range(1, 6):
if input_tree_excel.active.cell(temp_row, temp_column).value == paragraph_name:
num_row = temp_row + 1
num_colmun = temp_column + 1
temp_found_flag = True
print(' ->Found the number of '+ row_or_column +' ' + paragraph_name)
if temp_row >= max_number_of_serch_colmun:
temp_found_flag = True
print('<<<ERROR the search paragraph name can not be find in the Worksheet>>>')
sys.exit()
temp_row +=1
if row_or_column == 'row':
num_row_or_colmun = num_row
elif row_or_column == 'column':
num_row_or_colmun = num_colmun
return(num_row_or_colmun)
def insert_custom_excel_table(input_excel, worksheet_name ,start_row, start_column,custom_table_name):
##### init setting #####
max_num_row = 0
custom_table_row = 0
temp_size_column = 0
dict_input_num_column = ['']
Row_OF_Column_Range = 1
##### Main script prepared #####
input_tree_excel = input_excel
input_custom_table = openpyxl.load_workbook(custom_table_name)
input_custom_table.active = input_custom_table.sheetnames.index('_tmp_') #### Add for Network Sketcher
##### check number of table's row #####
for n in range(1, 10000):
if input_custom_table.active.cell(n, 1).value == '<END>':
max_num_row = n-1
break
elif n == 9999:
tkinter.messagebox.showerror('error', 'Uneble to find <END> on row 1 in the meta_excel_table_file or number of row over 9999')
return ('Uneble to find <END> on row 1')
##### Insert empty rows #####
for s in range(0, max_num_row ):
input_tree_excel = insert_excel_empty_row(input_tree_excel, worksheet_name, start_row+1+s)
##### Insert table with each column #####
for temp_row in range(1, max_num_row):
current_row = start_row + temp_row
custom_table_row = temp_row+1
temp_current_column = start_column + 1
#### Get number of column end #####
temp_flag_end = False
temp_column_end = 0
while (temp_flag_end == False):
temp_column_end += 1
if input_custom_table.active.cell(custom_table_row, temp_column_end + 1).value == '<END>':
temp_flag_end = True
elif temp_column_end == 9999:
tkinter.messagebox.showerror('error', 'Uneble to find <END> on any coulmn in the meta_excel_table_file or number of column over 9999')
break
#### Change to rows to new Column range#####
if input_custom_table.active.cell(custom_table_row, 1).value == '<RANGE>':
Row_OF_Column_Range = temp_row + 1
start_row -= 1
'''
ROW is <HEADER>
'''
elif input_custom_table.active.cell(custom_table_row , 1).value == '<HEADER>':
input_msg = input_custom_table.active.cell(custom_table_row, 2).value
temp_size_column = 0
for c in range(2, temp_column_end+1):
if input_custom_table.active.cell(custom_table_row, c+1).value != None or input_custom_table.active.cell(custom_table_row, c+1).value == '<END>':
input_num_column = int(input_custom_table.active.cell(Row_OF_Column_Range, c).value) + temp_size_column
write_excel_cell(input_excel, worksheet_name, current_row, temp_current_column, input_msg, input_num_column, 'TABLE_HEADER', 'NONE')
temp_current_column = temp_current_column + input_num_column
input_msg = input_custom_table.active.cell(custom_table_row, c + 1).value
elif input_custom_table.active.cell(custom_table_row, c+1).value == None:
temp_size_column = temp_size_column + int(input_custom_table.active.cell(Row_OF_Column_Range, c).value)
input_num_column = 0
temp_current_column = start_column + 1
### ROW is <END> ###
elif input_custom_table.active.cell(custom_table_row, 1).value == '<END>':
print('ROW is <END>')
'''
ROW is Normal
'''
else:
input_msg = input_custom_table.active.cell(custom_table_row, 2).value
for c in range(2, temp_column_end + 1):
#### Check cell_style - >buttom border line is covert to White ####
cell_style = 'TABLE_NORMAL'
write_style = 'NONE'
### set border first row and last row for normal###
if input_custom_table.active.cell(custom_table_row, c).value != None and input_custom_table.active.cell(custom_table_row + 1, c).value == '<WHITE>' and input_custom_table.active.cell(custom_table_row, c).value != '<WHITE>':
write_style = 'BOTTOM_SAME'
### set border first row and last row for sub_title###
if input_custom_table.active.cell(custom_table_row, c).value != None and input_custom_table.active.cell(custom_table_row + 1, c).value == None and input_custom_table.active.cell(custom_table_row + 1, c).value != '<END>' and input_custom_table.active.cell(custom_table_row + 1, c-1).value != '<END>':
write_style = 'BOTTOM_SAME'
if input_custom_table.active.cell(custom_table_row, c).value != None and input_custom_table.active.cell(custom_table_row + 1, 1).value != None and input_custom_table.active.cell(custom_table_row - 1, c).value != None and '>' not in input_custom_table.active.cell(custom_table_row - 1, c).value:
write_style = 'TOP_SAME'
if input_custom_table.active.cell(custom_table_row + 1, 1).value == '<END>':
write_style = 'NONE'
if input_custom_table.active.cell(custom_table_row, c).value == None and input_custom_table.active.cell(custom_table_row + 1, 1).value == '<END>':
write_style = 'TOP_SAME'
if input_custom_table.active.cell(custom_table_row, c).value == '<WHITE>' and input_custom_table.active.cell(custom_table_row + 1, 1).value == '<END>':
write_style = 'TOP_SAME'
### check sub_title###
if input_custom_table.active.cell(custom_table_row, c).value != None:
temp_first_character = input_custom_table.active.cell(custom_table_row, c).value[:1]
if temp_first_character != '>' and temp_first_character != '<':
cell_style = 'SUB_TITLE'
else:
cell_style = 'SUB_TITLE'
### check white###
if input_custom_table.active.cell(custom_table_row, c).value == '<WHITE>':
input_msg = ''
### check white###
if input_custom_table.active.cell(custom_table_row, c).value == '<EDGE>':
input_msg = ''
write_style = 'EDGE'
###Enable Disable Mark###
if input_custom_table.active.cell(custom_table_row, c + 1).value != None or input_custom_table.active.cell(custom_table_row, c + 1).value == '<END>':
input_num_column = int(input_custom_table.active.cell(Row_OF_Column_Range, c).value)
#### Specific mark are converted ####
input_msg = str(input_msg)
if input_msg == '<ENABLE>':
input_msg = ''
for t in range(1,int(input_num_column*2.4)):
input_msg = input_msg + ' '
input_msg = input_msg + Enable_mark
elif input_msg == '<DISABLE>':
input_msg = ''
for t in range(1,int(input_num_column*2.4)):
input_msg = input_msg + ' '
input_msg = input_msg + Disable_mark
elif input_msg == 'None':
input_msg = ''
#### sub main ####
write_excel_cell(input_excel, worksheet_name, current_row, temp_current_column, input_msg, input_num_column, cell_style, write_style)
temp_current_column = temp_current_column + input_num_column
input_msg = input_custom_table.active.cell(custom_table_row, c + 1).value.replace('>>', '') # add replace >> for Network Sketcher
elif input_custom_table.active.cell(custom_table_row, c+1).value == None:
input_num_column = int(input_custom_table.active.cell(Row_OF_Column_Range, c).value)
write_excel_cell(input_excel, worksheet_name, current_row, temp_current_column, input_msg, input_num_column, cell_style, write_style)
temp_current_column = temp_current_column + input_num_column
input_msg = input_custom_table.active.cell(custom_table_row, c + 1).value
input_msg = ''
input_num_column = 0
temp_current_column = start_column + 1
temp_size_column=0
return(input_tree_excel)
def diff_worksheets(COM_input_tree_excel, MAS_input_tree_excel, OPTION1, OPTION2):
format_number_of_column = 104 # format number of column. format border/width/height For Example, Column:A = 1 Column:AA = 27 Column:CZ = 104.
number_of_add_modify_rows = 10 # add number of coordinated empty rows under ended row.
empty_count = 0
COM_current_row_num = 2
MAS_current_row_num = 2
COM_current_bullet = None
MAS_current_bullet = None
empty_flag = False
OPTION1.insert(tkinter.END, '"Row number","Column number","Master sheet","Compared sheet"')
###Main###
while empty_count <= number_of_add_modify_rows:
for temp_column_num in range(2, format_number_of_column + 1):
###input bullet###
temp_MAS_str = str(MAS_input_tree_excel.active.cell(MAS_current_row_num,temp_column_num).value)
temp_COM_str = str(COM_input_tree_excel.active.cell(COM_current_row_num, temp_column_num).value)
if temp_MAS_str.startswith(second_paragraph_bullet_front) or temp_MAS_str.startswith(third_paragraph_bullet_front) or temp_MAS_str.startswith(fourth_paragraph_bullet_front) or temp_MAS_str.startswith(fifth_paragraph_bullet_front):
MAS_current_bullet = MAS_input_tree_excel.active.cell(MAS_current_row_num,temp_column_num).value
if temp_COM_str.startswith(second_paragraph_bullet_front) or temp_COM_str.startswith(third_paragraph_bullet_front) or temp_COM_str.startswith(fourth_paragraph_bullet_front) or temp_COM_str.startswith(fifth_paragraph_bullet_front):
COM_current_bullet = COM_input_tree_excel.active.cell(COM_current_row_num,temp_column_num).value
###check diff###
if str(MAS_input_tree_excel.active.cell(MAS_current_row_num,temp_column_num).value) != str(COM_input_tree_excel.active.cell(COM_current_row_num,temp_column_num).value):
if temp_COM_str.startswith('>') or Enable_mark in temp_COM_str or Disable_mark in temp_COM_str :
### Change Enable and Disable Mark to <Enable> and <Disable> because of tk can not use the specific mark.
temptemp_MAS_str = temp_MAS_str
temptemp_COM_str = temp_COM_str
if Enable_mark in temp_MAS_str:
temptemp_MAS_str = '<Enable>'
elif Disable_mark in temp_MAS_str:
temptemp_MAS_str = '<Disable>'
if Enable_mark in temp_COM_str:
temptemp_COM_str = '<Enable>'
elif Disable_mark in temp_COM_str:
temptemp_COM_str = '<Disable>'
#### write color####
OPTION1.insert(tkinter.END, '\n\"'+str(COM_current_row_num)+'\",\"'+str(temp_column_num)+'\",\"'+temptemp_MAS_str+'\",\"'+temptemp_COM_str+'\"')
if OPTION2 != 'ONLY_LOG':
COM_input_tree_excel.active.cell(COM_current_row_num,temp_column_num).font = openpyxl.styles.fonts.Font(name="Futura", size=11,color='FF0000')
else:
COM_input_tree_excel.active.cell(COM_current_row_num,temp_column_num).font = openpyxl.styles.fonts.Font(name="Futura", size=11,color='000000')
### flag check end of sheet###
if MAS_input_tree_excel.active.cell(MAS_current_row_num,temp_column_num).value != None:
empty_flag = False
empty_count = 0
if MAS_current_bullet != COM_current_bullet:
COM_current_row_num += 1
else:
MAS_current_row_num += 1
COM_current_row_num += 1
### check end of sheet###
if empty_flag == True:
empty_count += 1
empty_flag = True
return(COM_input_tree_excel)
'''
RUN GUI TREE MAKER
'''
class qui_tree_run():
def __init__(self):
# crate the root frame
root = tk.Tk()
root.title("EXCEL GUI TREE MAKER Ver 1.3 < Cisco Internal Use Only > ")
root.geometry("1024x800")
# Notebook
nb = ttk.Notebook(width=200, height=200)
# create Tabs
tab1 = tk.Frame(nb)
tab2 = tk.Frame(nb)
tab3 = tk.Frame(nb)
tab4 = tk.Frame(nb)
tab5 = tk.Frame(nb)
nb.add(tab2, text=' Excel Frame Editer ', padding=15)
nb.add(tab4, text=' Difference check ', padding=15)
nb.add(tab5, text=' DIFF to PowerPoint ', padding=15)
nb.add(tab1, text=' Create Excel Frame ', padding=15 )
nb.add(tab3, text=' Advanced Module ', padding=15)
nb.pack(expand=1, fill='both')
# TAB5 initial settings
self.flag_set_diff = False
'''
TAB1 <<CREATE EXCEL>>
'''
# label setting
label1_0 = tk.Label(tab1,text="Create Excel Frame file from META file",font=("",16),height=2,background="#ffffff")
label1_0.pack(fill="x")
# input file
frame1_1 = tk.Frame(tab1,pady=10)
frame1_1.pack()
label1_1 = tk.Label(frame1_1,font=("",14),text="INPUT File Path(Excel meta)")
label1_1.pack(side="left")
self.entry1_1 = tk.Entry(frame1_1,font=("",10),justify="left",width=60)
self.entry1_1.pack(side="left")
button1_1 = tk.Button(frame1_1,text="Browse...",font=("",10),width=8,command=lambda:self.click_action('1-1'))
button1_1.pack(side="left")
# output file
frame1_2 = tk.Frame(tab1,pady=10)
frame1_2.pack()
label1_2 = tk.Label(frame1_2,font=("",14),text="OUTPUT File Path(Excel frame)")
label1_2.pack(side="left")
self.entry1_2 = tk.Entry(frame1_2,font=("",10),justify="left",width=60)
self.entry1_2.pack(side="left")
button1_2 = tk.Button(frame1_2,text="Browse...",font=("",10),width=8,command=lambda:self.click_action('1-2'))
button1_2.pack(side="left")
# Run
button1_3 = tk.Button(tab1,text="CREATE",font=("",14),width=15,command=lambda:self.click_action('1-3'))
button1_3.pack()
'''
TAB2 <<EDIT EXCEL>>
'''
# self setting
self.input_tree_excel = None
self.selected_1 = None
self.selected_2 = None
self.selected_3 = None
self.selected_4 = None
self.selected_5 = None
self.selected_4_1 = None
self.selected_4_2 = None
self.selected_row_1 = None
self.selected_row_2 = None
self.selected_row_3 = None
self.selected_row_4 = None
self.selected_row_5 = None
self.temp_max_row = None
# label setting
label2_0 = tk.Label(tab2,text="Excel Frame Editer",font=("",16),height=1,background="#ffffff")
label2_0.grid(column=0, row=0)
# input file
frame2_1 = tk.Frame(tab2,pady=10)
frame2_1.grid(column=0, row=1, sticky = W)
label2_1 = tk.Label(frame2_1,font=("",14),text="<STEP1> Input File Path(Excel frame)",background="#fff2cc")
label2_1.grid(column=0, row=2, sticky = W)
self.entry2_1 = tk.Entry(frame2_1,font=("",10),justify="left",width=100)
self.entry2_1.grid(column=0, row=3)
button2_1 = tk.Button(frame2_1,text="Browse...",font=("",10),width=15,command=lambda:self.click_action('2-1'))
button2_1.grid(column=1, row=3)
label2_1_open = tk.Label(frame2_1,font=("",14),text=" ")
label2_1_open.grid(column=2, row=3 , sticky = W)
button2_1_open = tk.Button(frame2_1,text=" Open The Selected File",font=("",10),width=17,command=lambda:self.click_action('2-1-open'))
button2_1_open.grid(column=3, row=3)
def select_listbox2_1(event):
self.click_action('2-2')
def select_listbox2_2(event):