2026-05-20 21:39:12 +08:00

41 lines
2.0 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#r "nuget: DocumentFormat.OpenXml, 3.2.0"
using DocumentFormat.OpenXml;
using DocumentFormat.OpenXml.Packaging;
using DocumentFormat.OpenXml.Wordprocessing;
string outputPath = "C:/Users/Administrator/Desktop/xxx/宫崎骏简介.docx";
using var doc = WordprocessingDocument.Create(outputPath, WordprocessingDocumentType.Document);
var mainPart = doc.AddMainDocumentPart();
mainPart.Document = new Document();
var body = new Body();
mainPart.Document.Append(body);
// Title
var titlePara = new Paragraph(
new ParagraphProperties(new ParagraphStyleId() { Val = "Title" }),
new Run(new Text("宫崎骏简介"))
);
body.Append(titlePara);
// Content paragraph - 200 character introduction
string content = "宫崎骏Hayao Miyazaki1941年1月5日出生于日本东京都日本著名动画导演、漫画家及动画师吉卜力工作室的核心人物。他以其独特的创作风格和深刻的环保主题闻名于世代表作品包括《风之谷》《天空之城》《龙猫》《魔女宅急便》《红猪》《幽灵公主》《千与千寻》《哈尔的移动城堡》《悬崖上的金鱼姬》等。2003年他执导的《千与千寻》荣获奥斯卡最佳动画长片奖成为首位获得该奖项的非英语动画导演。宫崎骏的作品以细腻的情感、优美的画面和对自然与人类关系的深刻思考著称倡导和平、环保和对儿童纯真心灵的守护对全球动画产业产生了深远影响。";
var contentPara = new Paragraph(
new ParagraphProperties(new SpacingBetweenLines() { After = "200" }),
new Run(new Text(content))
);
body.Append(contentPara);
// Section properties (page setup)
var sectPr = new SectionProperties(
new PageSize() { Width = 12240, Height = 15840 }, // Letter size
new PageMargin() { Top = 1440, Right = 1440, Bottom = 1440, Left = 1440 }
);
body.Append(sectPr);
mainPart.Document.Save();
Console.WriteLine($"Created: {outputPath}");
Console.WriteLine($"Content length: {content.Length} characters");