fix: 里程碑2 最终评审 must-fix(header_row 接线 + formatting 回填)

This commit is contained in:
lhl
2026-08-09 03:25:32 +08:00
parent 3307d7ba72
commit eebed38886
4 changed files with 59 additions and 5 deletions
+33
View File
@@ -24,3 +24,36 @@ def test_parse_free_text_sheet(tmp_path):
result = ExcelParser().parse(path)
assert len(result.tables) == 1
assert result.tables[0].extraction_method == "llm_from_free_text"
def test_parse_uses_detected_header_row(tmp_path):
# 标题行(单格)在首行,真实表头在第二行
wb = new_workbook({
"機能一覧": [["機能一覧"], ["機能ID", "機能名"], ["A001", "社員登録"]],
})
path = save_workbook(tmp_path, wb)
result = ExcelParser().parse(path)
t = result.tables[0]
assert t.headers == ["機能ID", "機能名"]
assert len(t.rows) == 1
assert t.rows[0]["機能ID"].value == "A001"
def test_parse_attaches_strikethrough_formatting(tmp_path):
from copy import copy
from openpyxl import Workbook
wb = Workbook()
ws = wb.active
ws.title = "機能一覧"
ws["A1"] = "機能ID"
ws["B1"] = "機能名"
ws["A2"] = "A001"
ws["B2"] = "社員登録"
font = copy(ws["A2"].font)
font.strike = True
ws["A2"].font = font
path = save_workbook(tmp_path, wb)
result = ExcelParser().parse(path)
cv = result.tables[0].rows[0]["機能ID"]
assert cv.formatting is not None
assert cv.formatting.strikethrough is True