Skip to content

Commit

Permalink
改善清除舊資料處理邏輯
Browse files Browse the repository at this point in the history
  • Loading branch information
AlanJui committed Oct 7, 2024
1 parent f3480fa commit 123d697
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
8 changes: 7 additions & 1 deletion a700_産生作業用工作暫存檔.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,13 @@
sheet = wb.sheets['漢字注音'] # 選擇工作表
sheet.activate() # 將「漢字注音」工作表設為作用中工作表
sheet.range('A1').select() # 將 A1 儲存格設為作用儲存格
sheet.range('D3:R166').clear_contents() # 清除 C3:R166 範圍的內容

total_rows = wb.names['每頁總列數'].refers_to_range.value
cells_per_row = 4
end_of_rows = int((total_rows * cells_per_row ) + 2)
cells_range = f'D3:R{end_of_rows}'

sheet.range(cells_range).clear_contents() # 清除 C3:R{end_of_row} 範圍的內容

# 獲取 V3 儲存格的合併範圍
merged_range = sheet.range('V3').merge_area
Expand Down
4 changes: 0 additions & 4 deletions a701_作業中活頁檔填入漢字.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,6 @@
print("無法執行,可能原因:(1) 未指定輸入檔案;(2) 未找到作用中的 Excel 工作簿")
sys.exit(2)

# 清空儲存格內容
sheet = wb.sheets['漢字注音']
sheet.range('D3:R166').clear_contents() # 清除 C3:R166 範圍的內容

# 將待注音的漢字填入
fill_hanji_in_cells(wb)

Expand Down

0 comments on commit 123d697

Please sign in to comment.