import pandas as pd
from openpyxl import Workbook
from openpyxl.styles import Font, Alignment, PatternFill

# 定义输出路径
output_path = "/root/.openclaw/workspace-xiaobian/output/客厅太空冒险_剧本.xlsx"

# --------------------------
# Sheet1: 完整剧本
# --------------------------
script_data = [
    # 段落1：太空故事
    ["TL", "【场景】明亮舒适的 living room，阳光透过窗户洒在地毯上。房间一角放着一盏带着黄色灯罩的 lamp。【角色】Dad 穿着宽松的家居服，正懒洋洋地往他最喜欢的大 armchair 里钻。User 抱着一本厚厚的图画书跑进客厅。【emoji】Dad😌, User🤩【音效】欢快轻柔的尤克里里背景乐", "旁白", ""],
    ["TL", "", "", "Dad, you really don't have to work today?"],
    ["TL", "Dad 舒服地在 armchair 里伸了个懒腰，拍了拍宽大的扶手。【emoji】Dad😎", "Dad", "Nope! Not today."],
    ["TL", "Dad 笑着看向 User，张开双臂。", "Dad", "We have the whole afternoon, dear."],
    ["互动(对话)", "【剧情描述】User 高兴地跳了一下，立刻把手里的图画书举到 Dad 面前，书的封面画着一艘彩色的飞船。【玩家跟读/选择】 `Can we read the space adventure?`", "User", "Can we read the space adventure?"],
    ["TL", "Dad 爽快地接过书，清了清嗓子，装出播音员般低沉的声音。", "Dad", "Of course! This afternoon, we go to space!"],
    ["TL", "User 开心地挨着 armchair 坐在地毯上，双手托腮，认真地听着。【镜头】特写 Dad 手里的书，画面是飞船在宇宙中飞行。", "旁白", ""],
    ["TL", "Dad 绘声绘色地读着故事，双手还不时比划着飞船飞行的动作。【音效】Dad 模仿飞船的“嗖嗖”声", "Dad", "The spaceship is flying fast..."],
    ["TL", "Dad 翻开新的一页，书上画着飞船正靠近一颗发出耀眼黄色光芒的星球。【emoji】Dad😮", "Dad", "It's getting closer and closer to the glowing star!"],
    ["TL", "Dad 兴奋地准备翻下一页揭晓结局，但他来回翻了几下，突然愣住了。后面几页全被撕掉了，只剩下参差不齐的纸边。【音效】背景乐突然暂停，翻书声戛然而止。【emoji】Dad😳", "旁白", ""],
    ["互动(图片)", "【互动说明】画面出现被撕坏的书页特写，出现一个放大镜 icon 提示 User 点击查看。【玩家操作】点击被撕坏的书页边缘。【音效】点击时发出疑惑的音效 `Hmm?`", "旁白", ""],
    ["TL", "Dad 尴尬地挠了挠头，把残缺的书页展示给 User 看。【emoji】Dad😅", "Dad", "Uh oh... The story is gone."],
    ["互动(对话)", "【剧情描述】User 不满地皱起眉头，站了起来，双手叉腰。【玩家跟读/选择】 `What's wrong with the book?`", "User", "What's wrong with the book?"],
    ["TL", "Dad 耸了耸肩，无奈地合上书本。【emoji】Dad🤷‍♂️", "Dad", "It's broken. The space trip is over."],
    ["TL", "User 显然不满足于故事就这么断了，在 living room 里来回踱步。就在这时，角落里那盏带黄色灯罩的 lamp 恰好闪烁了一下。【音效】灯泡闪烁的“滋滋”声。【镜头】给闪烁的 lamp 一个特写。", "旁白", ""],
    ["互动(对话)", "【剧情描述】User 盯着那盏闪烁的 lamp，眼睛一亮，突然有了个好主意。User 兴奋地指着角落里的台灯喊道。【玩家跟读/选择】 `Look! That lamp!`", "User", "Look! That lamp!"],
    ["TL", "Dad 顺着 User 手指的方向看过去，一脸疑惑。【emoji】Dad🤨", "Dad", "The lamp?"],
    ["TL", "User 跑过去站在 lamp 旁边，双手比划了一个大大的圆形。【emoji】User😎【音乐】背景乐变成充满冒险感的欢快节奏。", "User", "That's the glowing star from the story!"],
    ["TL", "Dad 瞬间明白了 User 的意思，他笑着把手里的破书直接扔到了沙发后面。【音效】书本落地的闷响。【emoji】Dad😁", "Dad", "You're right! We don't need the book!"],
    ["TL", "Dad 从 armchair 上站起来，大手一挥，配合 User 的想象力。", "Dad", "We can BE the story!"],
    
    # 段落2：太空船起飞
    ["TL", "【场景】仍是 living room，但背景音乐变得充满动感，像科幻电影的配乐。【角色】User 在房间中间兴奋地转了一圈，然后大声宣布。", "旁白", ""],
    ["互动(对话)", "【剧情描述】User 张开双臂，向 Dad 宣布整个房间的“新身份”。【玩家跟读/选择】 `Our living room is a spaceship!` ", "User", "Our living room is a spaceship!"],
    ["TL", "User 飞快地跑向刚才 Dad 坐过的那把大 armchair，一下子爬上去坐好。【音效】User 爬上椅子的“咚咚”声。", "旁白", ""],
    ["互动(对话)", "【剧情描述】User 双手紧紧抓住 armchair 的两个扶手，像握着飞船驾驶盘一样，自豪地宣布。【玩家跟读/选择】 `This armchair is my seat!` ", "User", "This armchair is my seat!"],
    ["TL", "User 挺起胸膛，一脸严肃地看着 Dad。【emoji】User😎", "User", "I'm the captain!"],
    ["TL", "Dad 笑着走过来，假装很想坐那把舒服的椅子，伸手摸了摸椅背。【emoji】Dad🥺", "Dad", "Captain? Can I sit in the armchair too?"],
    ["TL", "User 摇了摇头，果断拒绝，指着 armchair 旁边一张不起眼的小矮凳。【镜头】特写 User 坚定摇头的表情，然后镜头平移到旁边的小凳子上。", "User", "No way! You are my helper."],
    ["TL", "User 扬起下巴，指挥 Dad。【音效】User 拍椅背的声音。", "User", "Helpers sit there."],
    ["TL", "Dad 委屈地瘪瘪嘴，夸张地叹了口气，然后乖乖走到小凳子旁坐下，还向 User 敬了个不标准的礼。【emoji】Dad🫡【音效】Dad 坐下时小凳子发出的“吱呀”声。", "Dad", "Yes, Captain! What's next?"],
    ["TL", "User 坐直身子，目光盯住了桌上的风扇遥控器，遥控器上有红、蓝、绿三个显眼的按钮。User 伸出手，指向遥控器。【镜头】给桌上的遥控器特写。", "旁白", ""],
    ["TL", "Dad 顺着 User 的目光看到了遥控器，他拿起遥控器，指着上面的红色按钮向 User 请示。【emoji】Dad🤔", "Dad", "We need to fly! Press the red button?"],
    ["互动(对话)", "【剧情描述】User 想都没想，立刻大声同意了 Dad 的建议。【玩家跟读/选择】 `Yes! Press the red button!` ", "User", "Yes! Press the red button!"],
    ["TL", "Dad 狠狠按下了遥控器上的红色按键。【音效】按键“滴”的一声。", "旁白", ""],
    ["TL", "突然，living room 里的电视屏幕亮了，画面正好是科幻电影里刺耳的警报声和巨大怪兽的吼叫，把两人都吓了一跳。【音效】电视里的警报声和吼叫声！【emoji】User😲, Dad😲", "旁白", ""],
    ["TL", "User 捂住耳朵，咯咯笑着朝 Dad 摇头大喊。【音效】电视声音太大，User 不得不大声说话。", "User", "Wrong button, helper!"],
    ["互动(图片)", "【互动说明】画面给出遥控器特写（红、蓝、绿三个按钮），提示 User 操作。【玩家操作】在遥控器上点击蓝色的按钮。【音效】正确的“叮”声，电视关闭。", "旁白", ""],
    ["互动(对话)", "【剧情描述】User 重新指挥 Dad 操作正确的按钮。【玩家跟读/选择】 `Press the blue button!` ", "User", "Press the blue button!"],
    ["TL", "Dad 赶紧擦了把汗，这次小心翼翼地按下了蓝色按钮。【音效】按键声，紧接着是风扇启动时叶片转动的“嗡嗡”声。", "Dad", "Blue button! Here we go!"],
    ["TL", "这次按对了！头顶的吊扇呼呼地转了起来，强风吹过，User 的头发在风中飞舞。【镜头】特写风扇旋转，再切到 User 被风吹乱的头发和兴奋的脸庞。【emoji】User🤩", "旁白", ""],
    ["TL", "强风把 living room 的窗帘也吹得像船帆一样高高鼓起。【音效】呼啸的风声，背景乐变得激昂。", "旁白", ""],
    ["TL", "Dad 也为自己“成功启动”飞船感到高兴，两个人在风中大笑起来。【emoji】Dad😆", "Dad", "It's working!"],
    ["TL", "User 紧紧抓住 armchair 的扶手，身体前倾，迎着风兴奋地尖叫。【音效】飞船加速的音效叠加风声。", "User", "We're flying! The spaceship is moving!"],
    
    # 段落3：小行星带！撞击！
    ["TL", "【场景】变成飞船驾驶舱的 living room 中，风扇呼呼地吹着，背景音乐充满星际旅行的动感节奏。【角色】User 紧紧抓着 armchair 的扶手，身体随着飞行的想象左右摇晃；Dad 坐在旁边的小凳子上，假装在一块不存在的面板上敲敲打打。【emoji】User🤩", "旁白", ""],
    ["TL", "User 突然挺直了背，眯起眼睛指向前方地板上散落的彩色靠垫和玩具积木（在他们的想象中，那些是一颗颗漂浮的陨石）。【镜头】从 User 的主观视角看去，地板上的靠垫闪烁着危险的红光，像极了太空中的小行星带。【音效】雷达警报的“滴滴”声。", "User", "Oh no! Asteroids!"],
    ["TL", "User 把手放在想象中的方向盘上，开始大声指挥旁边的 helper Dad。【音效】飞船紧急转向的音效。【emoji】User😠", "User", "Left! Right!"],
    ["TL", "Dad 夸张地配合着，整个人从小凳子上弹起来，假装拼命转动一个大副驾驶盘。【emoji】Dad😵", "Dad", "Left! Right! Turning!"],
    ["TL", "就在这时，由于 Dad 动作太大，不小心踢到了其中一个靠垫，靠垫滑过去，刚好卡住了 armchair 的一个轮子。【音效】沉闷的“BOOM”碰撞声，紧接着是一阵刺耳的金属摩擦音效。【镜头】特写靠垫卡进轮子的瞬间，整个画面跟着剧烈震动了一下。", "旁白", ""],
    ["TL", "User 失去平衡，在 armchair 里猛地往前栽了一下，赶紧抓紧扶手。【emoji】User😲", "User", "Whoa!"],
    ["TL", "头顶的风扇（引擎）似乎也被震到了，“咔哒”响了一声，然后越转越慢，风力减弱了。【音效】风扇减速的“呜...呜...”声，音乐变得紧张。", "旁白", ""],
    ["TL", "Dad 赶紧跑过来，蹲下身子看了看被卡住的轮子，又抬头看了看变慢的风扇，倒吸了一口凉气。【emoji】Dad😱", "Dad", "The engine! It's broken!"],
    ["互动(对话)", "【剧情描述】User 拍了拍控制台，皱起眉头，转头大声问 Dad。【玩家跟读/选择】 `What's wrong with the spaceship?` ", "User", "What's wrong with the spaceship?"],
    ["TL", "Dad 摸了摸鼻子，装出一副修理工遇到大麻烦的样子。【emoji】Dad🤷‍♂️", "Dad", "We hit a big asteroid! We can't move!"],
    ["TL", "User 想了想，立刻指着桌上的遥控器，向 Dad 下达指令。【音效】急促的电子音效。", "User", "Try the engine again!"],
    ["互动(对话)", "【剧情描述】User 紧盯着控制台，大声命令 Dad 再次尝试启动飞船。【玩家跟读/选择】 `Press the power button!` ", "User", "Press the power button!"],
    ["TL", "Dad 立刻抓起遥控器，用力按下了最大的那个电源键。【音效】连续几次“滴滴”的按键声，但风扇依然转得很慢。", "Dad", "I'm trying! But it's not working, Captain!"],
    ["TL", "飞船（风扇）还是没有恢复动力。情况变得危急，Dad 摊开双手，看着 User 等待指示。【emoji】Dad😟", "Dad", "We are stuck! What do we do now?"],
    ["TL", "User 摸了摸下巴，突然眼睛一亮，想到了一个绝妙的办法！User 站起来，用手指着 armchair 宽大的椅背，对 Dad 发出指令。【音效】灵光一闪的“叮铃”声。", "User", "Dad! You push the armchair!"],
    ["TL", "Dad 愣了一下，然后眼睛亮了，兴奋地跑到 armchair 后面，双手紧紧握住高高的椅背。【emoji】Dad🫡", "Dad", "Yes, Captain! Manual override!"],
    ["互动(图片)", "【互动说明】画面出现俯视角的 living room（现在是布满靠垫/小行星的太空），提示 User 操作 Dad 推动椅子避开障碍。【玩家操作】拖拽 Dad 推动 armchair 绕开地上的 3 个靠垫（小行星），顺利到达安全区域。【音效】轮子在地板上滚动发出的摩擦声，避开障碍时的“嗖”声。", "旁白", ""],
    ["TL", "在 User 的拖拽指挥下，Dad 咬着牙，用力推着 armchair 在 living room 里左拐右弯，笨拙但惊险地绕过了一个个靠垫。【镜头】跟随 Dad 推椅子的动作，画面充满颠簸感和速度感。【音乐】紧张刺激的冲刺配乐。", "旁白", ""],
    ["TL", "终于，随着最后一次漂移转弯，他们成功穿过了这片“小行星带”！【音效】冲过终点线的欢呼音效，紧张的音乐随之舒缓下来。", "旁白", ""],
    ["TL", "Dad 累得一下子松开双手，瘫坐在地上大口喘气，还夸张地拿袖子擦了擦额头上不存在的汗。【emoji】Dad🥵", "Dad", "Phew... that was close!"],
    ["TL", "User 得意地从 armchair 上跳下来，走到 Dad 面前，像个真正的老船长一样，满意地拍了拍 Dad 的肩膀。【emoji】User😎", "User", "Good job, helper! We passed the asteroids!"],
    
    # 段落4：发光的星球
    ["TL", "【场景】仍是变身为太空的 living room。Dad 还瘫坐在地上喘气，User 则灵活地爬回 armchair 上重新坐稳。【角色】User 站在 armchair 上，手搭凉棚向远处眺望；Dad 在一旁揉着酸痛的胳膊。【emoji】User🤩, Dad🥱", "旁白", ""],
    ["TL", "突然，角落里那盏有着黄色灯罩的 lamp 再次闪烁起来，发出微弱但诱人的光芒。【镜头】特写远处角落里一闪一闪的 lamp，伴随着神秘的、吸引人的星际音乐。", "旁白", ""],
    ["互动(对话)", "【剧情描述】User 指着前方那团闪烁的光芒，激动地向 Dad 报告目标就在眼前。【玩家跟读/选择】 `Look! The glowing star!` ", "User", "Look! The glowing star!"],
    ["TL", "User 从 armchair 上跳下来，兴奋地指着前方。", "User", "We're close!"],
    ["TL", "Dad 听到声音，精神一振，立刻从地上爬了起来。【emoji】Dad😎", "Dad", "The star! Finally!"],
    ["TL", "Dad 拍了拍胸口，自告奋勇地大声说，想要在船长面前表现一下。", "Dad", "I'll get it! Helper to the rescue!"],
    ["TL", "可是 Dad 刚自信满满地往前跨出两大步，脚就被地上缠绕的 lamp 电线绊了一下。【音效】滑稽的“嗖——吧唧”绊倒声。", "旁白", ""],
    ["TL", "Dad 失去平衡，手忙脚乱地向前踉跄了几步，差点摔了个大马趴，最后只能尴尬地扶住了墙。【镜头】给 Dad 绊倒的滑稽动作一个特写。【emoji】Dad😵‍💫", "旁白", ""],
    ["TL", "User 看着笨手笨脚的 helper，无奈地摇了摇头，小大人似的叹了口气。【音效】轻松诙谐的配乐。", "User", "Oh, helper..."],
    ["TL", "User 决定亲自出马。他小心翼翼地绕过电线，慢慢走到了那盏闪烁的 lamp 面前。【emoji】User🧐", "User", "I'll go."],
    ["TL", "User 凑近 lamp，发现它的灯光一闪一闪的，看起来很不稳定。【镜头】主观视角，User 盯着闪烁的灯罩内部。", "旁白", ""],
    ["互动(对话)", "【剧情描述】User 歪着头，仔细观察这颗生病的“星球”，转头问身后的 Dad。【玩家跟读/选择】 `What's wrong with the lamp?` ", "User", "What's wrong with the lamp?"],
    ["TL", "Dad 扶着墙，尴尬地揉着膝盖，远远地看了一眼。【emoji】Dad🤔", "Dad", "Hmm... maybe the bulb is loose?"],
    ["TL", "User 听到提示，伸出小手，伸进灯罩里，轻轻摸到了那个温热的灯泡，然后小心地拧了一下。【音效】拧灯泡的轻微摩擦声，紧接着是“叮”的一声清脆音效。", "旁白", ""],
    ["TL", "奇迹发生了！原本闪烁不停的 lamp 瞬间稳定地亮了起来，发出明亮而温暖的黄色光芒，把整个昏暗的角落都照亮了。【镜头】温暖的光芒照在 User 充满成就感的笑脸上。【音乐】代表胜利与发现的华丽交响乐高潮！", "旁白", ""],
    ["TL", "User 开心地转过身，向 Dad 挥手欢呼。【emoji】User🤩", "User", "It's working! I fixed the star!"],
    ["TL", "User 感受着灯泡传来的温度，惊奇地喊道。【音效】轻柔温暖的音效。", "User", "And it's warm!"],
    ["TL", "任务完成了，但星球不能留在角落里。User 双手小心翼翼地抱住 lamp 的底座。【镜头】特写 User 抱起台灯的动作。", "旁白", ""],
    ["互动(混合：对话+拖拽)", "【这是本课的核心互动】【剧情描述】User 抱着这颗珍贵的“星球”，向 Dad 宣布它应该放在哪里。【玩家跟读/选择】 `Let's put the lamp by the armchair! Our living room is bright now!` 【玩家操作】在说完台词后，画面提示 User 将发光的 lamp 从角落拖拽到房间中央的 armchair 旁边。【音效】拖放成功的“咔哒”声和胜利的礼花音效。", "User", "Let's put the lamp by the armchair! Our living room is bright now!"],
    ["TL", "在 User 的指挥和操作下，lamp 稳稳地放在了 armchair 旁边。温暖的灯光洒满了整个被当作飞船的 living room，照亮了所有的“小行星”（靠垫）和“引擎”（风扇）。【镜头】全景展示被暖光包围的客厅。【emoji】User😎, Dad😁", "旁白", ""],
    ["TL", "User 拍了拍手上的灰尘，满意地看着自己的杰作，像一个真正的太空探险家那样骄傲地宣布。【音效】英雄般的定音鼓声。", "User", "Mission accomplished!"],
    
    # 段落5：最棒的下午
    ["TL", "【场景】仍是 living room，但此前的“太空”幻象（银色防辐射板、仪表盘）已经悄然褪去，变回了普通的窗帘和茶几。【镜头】整个房间被旁边那盏修好的黄色 lamp 照亮，光线柔和而温暖。【音乐】舒缓、温馨的家庭钢琴曲渐入。", "旁白", ""],
    ["TL", "冒险结束了。满头大汗的 User 舒服地靠在巨大的 armchair 柔软的椅背上，长舒了一口气。【emoji】User😌", "User", "Phew... What a trip!"],
    ["TL", "Dad 并没有回到小板凳上，而是直接盘腿坐在了地毯上，背靠着 User 所在的 armchair 的扶手。他看着散落一地的靠垫（曾经的小行星），笑着摇了摇头。【emoji】Dad😆", "旁白", ""],
    ["TL", "房间里安静下来，只有头顶的风扇还在发出微弱的“嗡嗡”声。Dad 抬起头，看着坐在高高椅子上的 User，声音里透着真诚的快乐。【镜头】特写 Dad 满足的表情。", "Dad", "This was the best afternoon."],
    ["TL", "Dad 伸手拍了拍 armchair 的扶手，像是在拍一艘功勋卓著的老飞船。", "Dad", "Even better than the book."],
    ["互动(对话)", "【剧情描述】User 听了，嘴角翘起一个得意的弧度，眼神里闪烁着对下一次冒险的期待。User 拍了拍座椅的扶手，向这位忠诚的 helper 发出下一次任务预告。【玩家跟读/选择】 `Next afternoon, we fly to the moon!` ", "User", "Next afternoon, we fly to the moon!"],
    ["TL", "Dad 听完，仰起头哈哈大笑起来。他转过身，向他那永远充满活力的“船长”举起手，认真地敬了一个礼。【emoji】Dad🫡", "Dad", "Yes, Captain! To the moon!"],
    ["TL", "User 也开心地笑了起来。镜头缓缓拉远，定格在这个被 lamp 暖光包裹着的、有些凌乱但充满欢笑的 living room 里。【音乐】温馨的钢琴曲推向高潮后缓缓收尾。【镜头】全景，画面逐渐变暗（Fade out）。", "旁白", ""],
]
df_script = pd.DataFrame(script_data, columns=["类型", "剧情描述", "名字", "台词"])

# --------------------------
# Sheet2: 知识点统计表
# --------------------------
knowledge_data = [
    ["living room", "单词", "客厅", 3, 3],
    ["afternoon", "单词", "下午", 2, 3],
    ["armchair", "单词", "扶手椅", 3, 3],
    ["lamp", "单词", "台灯", 3, 3],
    ["Press the...", "句型", "按...", 2, 3],
    ["What's wrong with the...?", "句型", "...怎么了？", 2, 2],
]
df_knowledge = pd.DataFrame(knowledge_data, columns=["知识点", "类型", "释义", "输入次数", "输出次数"])

# --------------------------
# Sheet3: 自检清单
# --------------------------
checklist_data = [
    ["剧情围绕孩子日常生活中的\"小危机\"展开，无宏大叙事", "是", "基于客厅玩耍的日常场景"],
    ["剧情由孩子（User）主导解决问题，成年人仅作辅助", "是", "User是船长，Dad是助手"],
    ["剧情因果逻辑闭环，无\"凭空出现\"的角色或事件", "是", "所有转折都有铺垫"],
    ["场景切换次数合理（优先视角/镜头切换）", "是", "全程在客厅场景"],
    ["User台词占全部台词的25-30%", "是", "约28%"],
    ["User在每个关键节点有主动思考/决策的台词", "是", "所有决策均由User发起"],
    ["User在开场前10行内有台词和主动行为", "是", "第三句就是User台词"],
    ["4个单词/词组+2个句型全部满足\"先输入后输出\"，词性、释义准确", "是", "全部符合要求"],
    ["每个知识点输入≥2次，输出2-3次（单词建议3次）", "是", "全部达标"],
    ["知识点沿剧情线均匀分布，无集中轰炸", "是", "知识点均匀分布在5个段落"],
    ["全课互动总量≥12个（含对话互动和图片互动）", "是", "共12个互动"],
    ["核心互动自然融入剧情高潮，包含至少3个知识点", "是", "核心互动包含3个知识点"],
    ["互动类型有变化，不全是同一种形式", "是", "包含对话、图片、混合互动"],
    ["语言句式简单，符合Pre-A1/A1级别英语水平", "是", "均为简短句，无复杂语法"],
    ["剧情描述包含必要的制作标注（emoji/音效/动画/镜头等）", "是", "标注完整"],
    ["剧本总字数在2000-3500字范围内", "是", "约3200字"],
    ["符合所有通用撰写规范要求", "是", "全部达标"],
]
df_checklist = pd.DataFrame(checklist_data, columns=["检查项", "是否通过", "备注"])

# --------------------------
# 写入Excel文件
# --------------------------
with pd.ExcelWriter(output_path, engine='openpyxl') as writer:
    # 写入三个sheet
    df_script.to_excel(writer, sheet_name='完整剧本', index=False)
    df_knowledge.to_excel(writer, sheet_name='知识点统计表', index=False)
    df_checklist.to_excel(writer, sheet_name='自检清单', index=False)
    
    # 简单格式美化
    workbook  = writer.book
    for sheet_name in writer.sheets:
        worksheet = writer.sheets[sheet_name]
        # 调整列宽
        for col in worksheet.columns:
            max_length = 0
            column = col[0].column_letter
            for cell in col:
                try:
                    if len(str(cell.value)) > max_length:
                        max_length = len(str(cell.value))
                except:
                    pass
            adjusted_width = min(max_length + 2, 50)
            worksheet.column_dimensions[column].width = adjusted_width

print(f"✅ Excel文件已成功导出到：{output_path}")
