Skip to content

Commit 19e4b32

Browse files
committed
Fixed #526
* The code already have and supported the choice of worksheet * Enhance code for better error handling and show which worksheet is currently using/working Signed-off-by: Chin Yeung Li <[email protected]>
1 parent 8527245 commit 19e4b32

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

CHANGELOG.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,12 @@
11
==============================
22
Changelog
3+
2023-xx-xx
4+
Release x.x.x
5+
6+
* The tool will now show which worksheet (if .xlsx input) is the tool working on
7+
* Error handling if defined worksheet does not exist
8+
9+
310
2023-03-09
411
Release 8.0.0
512

src/attributecode/util.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -680,10 +680,16 @@ def load_excel(location, worksheet=None):
680680
# This is to prevent showing the: warn("Workbook contains no default style, apply openpyxl's default")
681681
with warnings.catch_warnings(record=True):
682682
input_bom = openpyxl.load_workbook(location)
683+
sheetnames = input_bom.sheetnames
683684
if worksheet:
685+
if worksheet not in sheetnames:
686+
import sys
687+
print("The input worksheet name does not exist. Exiting.")
688+
sys.exit(1)
684689
sheet_obj = input_bom[worksheet]
685690
else:
686691
sheet_obj = input_bom.active
692+
print("Working on the " + sheet_obj.title + " worksheet.")
687693
max_col = sheet_obj.max_column
688694

689695
index = 1

0 commit comments

Comments
 (0)