import openpyxl from openpyxl.styles import Font, Alignment, PatternFill, Border, Side wb = openpyxl.Workbook() ws = wb.active ws.title = "U23_L2_起" ws.column_dimensions['A'].width = 12 ws.column_dimensions['B'].width = 45 ws.column_dimensions['C'].width = 12 ws.column_dimensions['D'].width = 42 header_font = Font(bold=True, size=11) header_fill = PatternFill(start_color="D9D9D9", end_color="D9D9D9", fill_type="solid") header_align = Alignment(horizontal="center", vertical="center", wrap_text=True) cell_align = Alignment(vertical="top", wrap_text=True) thin_border = Border( left=Side(style="thin"), right=Side(style="thin"), top=Side(style="thin"), bottom=Side(style="thin") ) headers = ["类型", "剧情描述", "角色名", "编剧台词"] for col, h in enumerate(headers, 1): cell = ws.cell(row=1, column=col, value=h) cell.font = header_font cell.fill = header_fill cell.alignment = header_align cell.border = thin_border rows = [ ["TL", '【场景】May农场(悬挂"Desert Fruit Tasting"横幅,展台摆满水果,记者扛摄像机走动)\n【角色】User、May', "", ""], ["", "May在农场入口迎接User", "", ""], ["", "", "May", "Hi! Welcome to the fruit tasting!"], ["中互动", "", "User", "I love fruit!"], ["", "May开心地点头,指向远处Sam的展位", "", ""], ["", "", "May", "I am so happy!"], ["", "", "May", "But today, we have one big job."], ["", "User顺着May手指方向看去——Sam在巨型Pineapple旁来回踱步,满头大汗", "", ""], ["", "", "May", "Sam needs our help."], ["", "", "May", "Come!"], ["TL", "【角色】Sam、记者、Kalab", "", ""], ["", "User和May走到Sam展位前。记者举着摄像机对准巨型Pineapple", "", ""], ["", "", "记者", "Tell us about your pineapple!"], ["", "Sam满脸通红,声音越说越小", "", ""], ["", "", "Sam", "My pineapple is big."], ["", "", "Sam", "Very big."], ["", "", "Sam", "I... I am sorry."], ["", "记者们面面相觑。Sam低下头。User看不下去,跳出来", "", ""], ["中互动", "", "User", "Sam grew this pineapple!"], ["", "Kalab突然挤进镜头前,挡住Sam", "", ""], ["", "", "Kalab", "Look at my golden kiwi!"], ["", "【插入图】Kalab的黄金Kiwi特写——巨大、金黄、闪闪发光", "", ""], ["", "", "Kalab", "Two hundred days of sun!"], ["", "", "Kalab", "The best fruit in the desert!"], ["TL", "【角色】User、May、Sam(记者和Kalab退到背景)", "", ""], ["", "May皱眉,拉User到一旁", "", ""], ["", "", "May", "I do not like him."], ["中互动", "", "User", "I do not like that kiwi."], ["", "May点头,转身走向沮丧的Sam", "", ""], ["", "", "May", "Do not worry, Sam."], ["", "", "May", "What fruit do you like?"], ["", "", "May", "I like your pineapple!"], ["中互动", "", "User", "I like Sam's pineapple too!"], ["", "Sam终于抬起头,稍稍振作。May压低声音", "", ""], ["TL", "【角色】User、May、Sam、Jack", "", ""], ["", "", "May", "Tom is the judge."], ["", "", "May", "He is our friend."], ["", "", "Sam", "Tom will pick my pineapple!"], ["", "Sam露出笑容。User和May交换欣慰的眼神", "", ""], ["", "【画外音】低沉的声音从背后传来", "", ""], ["", "", "Jack", "...Not at all."], ["", "三人同时转身。Jack倚在栅栏边,神情严肃,目光穿过会场——落在远处Tom身上。画面定格。", "", ""], ] tl_fill = PatternFill(start_color="E8F0FE", end_color="E8F0FE", fill_type="solid") interact_fill = PatternFill(start_color="FFF2CC", end_color="FFF2CC", fill_type="solid") for i, row in enumerate(rows, 2): for col, val in enumerate(row, 1): cell = ws.cell(row=i, column=col, value=val) cell.alignment = cell_align cell.border = thin_border if row[0] == "TL": cell.fill = tl_fill elif row[0] == "中互动": cell.fill = interact_fill ws.freeze_panes = "A2" output_path = "/root/.openclaw/workspace-xiaobian/output/U23_L2_起_剧本V1.xlsx" wb.save(output_path) print(f"Saved: {output_path}")