-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
253 additions
and
91 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,107 @@ | ||
import os | ||
import sys | ||
|
||
import xlwings as xw | ||
|
||
from mod_file_access import ( | ||
copy_excel_sheet, | ||
get_han_ji_khoo, | ||
get_sound_type, | ||
reset_han_ji_piau_im_cells, | ||
) | ||
from p702_Ca_Han_Ji_Thak_Im import ca_han_ji_thak_im | ||
|
||
# from p703_Kong_Un_Ca_Thak_Im import ca_han_ji_thak_im | ||
|
||
# (0) 取得專案根目錄。 | ||
# 使用已打開且處於作用中的 Excel 工作簿 | ||
try: | ||
wb = xw.apps.active.books.active | ||
except Exception as e: | ||
print(f"發生錯誤: {e}") | ||
print("無法找到作用中的 Excel 工作簿") | ||
sys.exit(2) | ||
|
||
# 獲取活頁簿的完整檔案路徑 | ||
file_path = wb.fullname | ||
print(f"完整檔案路徑: {file_path}") | ||
|
||
# 獲取活頁簿的檔案名稱(不包括路徑) | ||
file_name = wb.name | ||
print(f"檔案名稱: {file_name}") | ||
|
||
# 顯示「已輸入之拼音字母及注音符號」 | ||
named_range = wb.names['顯示注音輸入'] # 選擇名為 "顯示注音輸入" 的命名範圍# 選擇名為 "顯示注音輸入" 的命名範圍 | ||
named_range.refers_to_range.value = True | ||
|
||
# (1) A720: 將 V3 儲存格內的漢字,逐個填入標音用方格。 | ||
sheet = wb.sheets['漢字注音'] # 選擇工作表 | ||
sheet.activate() # 將「漢字注音」工作表設為作用中工作表 | ||
sheet.range('A1').select() # 將 A1 儲存格設為作用儲存格 | ||
|
||
# (2) A731: 自動為漢字查找讀音,並抄寫到漢字的上方(拼音)及下方(注音)。 | ||
type = get_sound_type(wb) | ||
han_ji_khoo = get_han_ji_khoo(wb) | ||
if han_ji_khoo == "河洛話" and type == "白話音": | ||
ca_han_ji_thak_im( | ||
wb=wb, | ||
sheet_name='漢字注音', | ||
cell='V3', | ||
hue_im="白話音", | ||
han_ji_khoo="河洛話", | ||
db_name='Ho_Lok_Ue.db', | ||
module_name='mod_河洛話', | ||
function_name='han_ji_ca_piau_im', | ||
) | ||
elif han_ji_khoo == "河洛話" and type == "文讀音": | ||
ca_han_ji_thak_im( | ||
wb=wb, | ||
sheet_name='漢字注音', | ||
cell='V3', | ||
hue_im="文讀音", | ||
han_ji_khoo="河洛話", | ||
db_name='Ho_Lok_Ue.db', | ||
module_name='mod_河洛話', | ||
function_name='han_ji_ca_piau_im', | ||
) | ||
elif han_ji_khoo == "廣韻": | ||
ca_han_ji_thak_im( | ||
wb=wb, | ||
sheet_name='漢字注音', | ||
cell='V3', | ||
hue_im="文讀音", | ||
han_ji_khoo="廣韻", | ||
db_name='Kong_Un.db', | ||
module_name='mod_廣韻', | ||
function_name='han_ji_ca_piau_im', | ||
) | ||
else: | ||
print("無法執行漢字標音作業,請確認【env】工作表【語音類型】及【漢字庫】欄位的設定是否正確!") | ||
sys.exit(2) | ||
|
||
# (3) A740: 將【漢字注音】工作表的內容,轉成 HTML 網頁檔案。 | ||
# tng_sing_bang_iah(wb, '漢字注音', 'V3') | ||
|
||
# (4) A750: 將 Tai_Gi_Zu_Im_Bun.xlsx 檔案,依 env 工作表的設定,另存新檔到指定目錄。 | ||
try: | ||
file_name = str(wb.names['TITLE'].refers_to_range.value).strip() | ||
except KeyError: | ||
# print("未找到命名範圍 'TITLE',使用預設名稱") | ||
# file_name = "default_file_name.xlsx" # 提供一個預設檔案名稱 | ||
setting_sheet = wb.sheets["env"] | ||
file_name = str( | ||
setting_sheet.range("C4").value | ||
).strip() | ||
|
||
# 設定檔案輸出路徑,存於專案根目錄下的 output2 資料夾 | ||
output_path = wb.names['OUTPUT_PATH'].refers_to_range.value | ||
new_file_path = os.path.join( | ||
".\\{0}".format(output_path), | ||
f"【河洛話注音】{file_name}.xlsx") | ||
|
||
# 儲存新建立的工作簿 | ||
wb.save(new_file_path) | ||
|
||
# 保存 Excel 檔案 | ||
# wb.close() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
<!DOCTYPE html> | ||
<html lang="zh-TW"> | ||
<head> | ||
<title>《永遇樂.京口北固亭懷古》</title> | ||
<meta charset="UTF-8"> | ||
<link rel="stylesheet" href="assets/styles/styles.css"> | ||
</head> | ||
<body> | ||
《永遇樂.京口北固亭懷古》 | ||
<div class='separator' style='clear: both'> | ||
<a href='圖片' style='display: block; padding: 1em 0; text-align: center'> | ||
<img alt='《永遇樂.京口北固亭懷古》' border='0' width='400' data-original-height='630' data-original-width='1200' | ||
src='https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiMXDc8Dy75HP0K1mpD_DcsJ0eEOKYEYTMgss-mT7y7nQ3ByINMrFPh479b60e-NXICkuMXh8vziKDi0esuL8lNn8hRxD036_r56-E9DHPgui2nmRfrz6Odv2E8bPNcgxUbV5lSBQWAHnk4ZkmZuaniYTyIB9FDbu2sdxNn91FNm6Er-0LhE6M3tfyJ/s756/cheng3-khi3-ko.jpeg' /> | ||
</a> | ||
</div> | ||
|
||
<div class='fifteen_yin'><p> | ||
<ruby><rb>千</rb><rp>(</rp><rt>堅一出</rt><rp>)</rp></ruby> <ruby><rb>古</rb><rp>(</rp><rt>沽二求</rt><rp>)</rp></ruby> <ruby><rb>江</rb><rp>(</rp><rt>江一求</rt><rp>)</rp></ruby> <ruby><rb>山</rb><rp>(</rp><rt>干一時</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>英</rb><rp>(</rp><rt>經一英</rt><rp>)</rp></ruby> <ruby><rb>雄</rb><rp>(</rp><rt>恭五喜</rt><rp>)</rp></ruby> <ruby><rb>無</rb><rp>(</rp><rt>艍五門</rt><rp>)</rp></ruby> <ruby><rb>覓</rb><rp>(</rp><rt>皆七門</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>孫</rb><rp>(</rp><rt>君一時</rt><rp>)</rp></ruby> <ruby><rb>仲</rb><rp>(</rp><rt>恭七地</rt><rp>)</rp></ruby> <ruby><rb>謀</rb><rp>(</rp><rt>沽五門</rt><rp>)</rp></ruby> <ruby><rb>處</rb><rp>(</rp><rt>艍二出</rt><rp>)</rp></ruby><span>。</span> | ||
<ruby><rb>舞</rb><rp>(</rp><rt>艍二門</rt><rp>)</rp></ruby> <ruby><rb>榭</rb><rp>(</rp><rt>迦七時</rt><rp>)</rp></ruby> <ruby><rb>歌</rb><rp>(</rp><rt>瓜一求</rt><rp>)</rp></ruby> <ruby><rb>臺</rb><rp>(</rp><rt>皆五地</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>風</rb><rp>(</rp><rt>公一喜</rt><rp>)</rp></ruby> <ruby><rb>流</rb><rp>(</rp><rt>丩五柳</rt><rp>)</rp></ruby> <ruby><rb>總</rb><rp>(</rp><rt>公二曾</rt><rp>)</rp></ruby> <ruby><rb>被</rb><rp>(</rp><rt>伽七頗</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>雨</rb><rp>(</rp><rt>艍二英</rt><rp>)</rp></ruby> <ruby><rb>打</rb><rp>(</rp><rt>監二地</rt><rp>)</rp></ruby> <ruby><rb>風</rb><rp>(</rp><rt>公一喜</rt><rp>)</rp></ruby> <ruby><rb>吹</rb><rp>(</rp><rt>檜一出</rt><rp>)</rp></ruby> <ruby><rb>去</rb><rp>(</rp><rt>艍二去</rt><rp>)</rp></ruby><span>。</span> | ||
<ruby><rb>斜</rb><rp>(</rp><rt>瓜八出</rt><rp>)</rp></ruby> <ruby><rb>陽</rb><rp>(</rp><rt>姜五英</rt><rp>)</rp></ruby> <ruby><rb>草</rb><rp>(</rp><rt>交二出</rt><rp>)</rp></ruby> <ruby><rb>樹</rb><rp>(</rp><rt>艍七時</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>尋</rb><rp>(</rp><rt>金五時</rt><rp>)</rp></ruby> <ruby><rb>常</rb><rp>(</rp><rt>姜五時</rt><rp>)</rp></ruby> <ruby><rb>巷</rb><rp>(</rp><rt>江七喜</rt><rp>)</rp></ruby> <ruby><rb>陌</rb><rp>(</rp><rt>經八門</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>人</rb><rp>(</rp><rt>巾五入</rt><rp>)</rp></ruby> <ruby><rb>道</rb><rp>(</rp><rt>高七地</rt><rp>)</rp></ruby> <ruby><rb>寄</rb><rp>(</rp><rt>居三求</rt><rp>)</rp></ruby> <ruby><rb>奴</rb><rp>(</rp><rt>沽五柳</rt><rp>)</rp></ruby> <ruby><rb>曾</rb><rp>(</rp><rt>經五曾</rt><rp>)</rp></ruby> <ruby><rb>住</rb><rp>(</rp><rt>艍七曾</rt><rp>)</rp></ruby><span>。</span> | ||
<ruby><rb>想</rb><rp>(</rp><rt>恭二時</rt><rp>)</rp></ruby> <ruby><rb>當</rb><rp>(</rp><rt>公一地</rt><rp>)</rp></ruby> <ruby><rb>年</rb><rp>(</rp><rt>堅五柳</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>金</rb><rp>(</rp><rt>金一求</rt><rp>)</rp></ruby> <ruby><rb>戈</rb><rp>(</rp><rt>高一求</rt><rp>)</rp></ruby> <ruby><rb>鐵</rb><rp>(</rp><rt>堅四他</rt><rp>)</rp></ruby> <ruby><rb>馬</rb><rp>(</rp><rt>膠二毛</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>氣</rb><rp>(</rp><rt>居三去</rt><rp>)</rp></ruby> <ruby><rb>吞</rb><rp>(</rp><rt>君一他</rt><rp>)</rp></ruby> <ruby><rb>萬</rb><rp>(</rp><rt>干七門</rt><rp>)</rp></ruby> <ruby><rb>里</rb><rp>(</rp><rt>居二柳</rt><rp>)</rp></ruby> <ruby><rb>如</rb><rp>(</rp><rt>艍五入</rt><rp>)</rp></ruby> <ruby><rb>虎</rb><rp>(</rp><rt>沽二喜</rt><rp>)</rp></ruby><span>。</span> | ||
</p><p> | ||
<ruby><rb>元</rb><rp>(</rp><rt>觀五語</rt><rp>)</rp></ruby> <ruby><rb>嘉</rb><rp>(</rp><rt>膠一求</rt><rp>)</rp></ruby> <ruby><rb>草</rb><rp>(</rp><rt>交二出</rt><rp>)</rp></ruby> <ruby><rb>草</rb><rp>(</rp><rt>交二出</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>封</rb><rp>(</rp><rt>公一喜</rt><rp>)</rp></ruby> <ruby><rb>狼</rb><rp>(</rp><rt>公五柳</rt><rp>)</rp></ruby> <ruby><rb>居</rb><rp>(</rp><rt>居一求</rt><rp>)</rp></ruby> <ruby><rb>胥</rb><rp>(</rp><rt>艍一時</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>贏</rb><rp>(</rp><rt>驚五英</rt><rp>)</rp></ruby> <ruby><rb>得</rb><rp>(</rp><rt>經四地</rt><rp>)</rp></ruby> <ruby><rb>倉</rb><rp>(</rp><rt>公一出</rt><rp>)</rp></ruby> <ruby><rb>皇</rb><rp>(</rp><rt>公五喜</rt><rp>)</rp></ruby> <ruby><rb>北</rb><rp>(</rp><rt>公四邊</rt><rp>)</rp></ruby> <ruby><rb>顧</rb><rp>(</rp><rt>沽三求</rt><rp>)</rp></ruby><span>。</span> | ||
<ruby><rb>四</rb><rp>(</rp><rt>艍三時</rt><rp>)</rp></ruby> <ruby><rb>十</rb><rp>(</rp><rt>金八時</rt><rp>)</rp></ruby> <ruby><rb>三</rb><rp>(</rp><rt>甘一時</rt><rp>)</rp></ruby> <ruby><rb>年</rb><rp>(</rp><rt>堅五柳</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>望</rb><rp>(</rp><rt>江七門</rt><rp>)</rp></ruby> <ruby><rb>中</rb><rp>(</rp><rt>恭一地</rt><rp>)</rp></ruby> <ruby><rb>猶</rb><rp>(</rp><rt>丩五英</rt><rp>)</rp></ruby> <ruby><rb>記</rb><rp>(</rp><rt>居三求</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>烽</rb><rp>(</rp><rt>公一喜</rt><rp>)</rp></ruby> <ruby><rb>火</rb><rp>(</rp><rt>扛二喜</rt><rp>)</rp></ruby> <ruby><rb>揚</rb><rp>(</rp><rt>恭五英</rt><rp>)</rp></ruby> <ruby><rb>州</rb><rp>(</rp><rt>丩一曾</rt><rp>)</rp></ruby> <ruby><rb>路</rb><rp>(</rp><rt>沽七柳</rt><rp>)</rp></ruby><span>。</span> | ||
<ruby><rb>可</rb><rp>(</rp><rt>高二去</rt><rp>)</rp></ruby> <ruby><rb>堪</rb><rp>(</rp><rt>甘一去</rt><rp>)</rp></ruby> <ruby><rb>回</rb><rp>(</rp><rt>檜五喜</rt><rp>)</rp></ruby> <ruby><rb>首</rb><rp>(</rp><rt>丩二時</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>佛</rb><rp>(</rp><rt>君八喜</rt><rp>)</rp></ruby> <ruby><rb>狸</rb><rp>(</rp><rt>居五柳</rt><rp>)</rp></ruby> <ruby><rb>祠</rb><rp>(</rp><rt>艍五時</rt><rp>)</rp></ruby> <ruby><rb>下</rb><rp>(</rp><rt>膠七喜</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>一</rb><rp>(</rp><rt>巾四英</rt><rp>)</rp></ruby> <ruby><rb>片</rb><rp>(</rp><rt>堅三頗</rt><rp>)</rp></ruby> <ruby><rb>神</rb><rp>(</rp><rt>巾五時</rt><rp>)</rp></ruby> <ruby><rb>鴉</rb><rp>(</rp><rt>膠一英</rt><rp>)</rp></ruby> <ruby><rb>社</rb><rp>(</rp><rt>迦七時</rt><rp>)</rp></ruby> <ruby><rb>鼓</rb><rp>(</rp><rt>沽二求</rt><rp>)</rp></ruby><span>。</span> | ||
<ruby><rb>憑</rb><rp>(</rp><rt>巾五邊</rt><rp>)</rp></ruby> <ruby><rb>誰</rb><rp>(</rp><rt>姜五時</rt><rp>)</rp></ruby> <ruby><rb>問</rb><rp>(</rp><rt>君七門</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>廉</rb><rp>(</rp><rt>兼五柳</rt><rp>)</rp></ruby> <ruby><rb>頗</rb><rp>(</rp><rt>高二頗</rt><rp>)</rp></ruby> <ruby><rb>老</rb><rp>(</rp><rt>高二柳</rt><rp>)</rp></ruby> <ruby><rb>矣</rb><rp>(</rp><rt>居二英</rt><rp>)</rp></ruby><span>,</span> | ||
<ruby><rb>尚</rb><rp>(</rp><rt>恭七時</rt><rp>)</rp></ruby> <ruby><rb>能</rb><rp>(</rp><rt>經五柳</rt><rp>)</rp></ruby> <ruby><rb>飯</rb><rp>(</rp><rt>觀七喜</rt><rp>)</rp></ruby> <ruby><rb>否</rb><rp>(</rp><rt>沽二喜</rt><rp>)</rp></ruby><span>。</span> | ||
</p></div> | ||
</body> | ||
</html> | ||
|
Oops, something went wrong.