c# - power point interop API - TextRange 中的多段无法正常工作
问题描述
我正在尝试使用互操作 API 生成 pptx 文件,但我需要在一个 TextRange(形状)中组合两个段落,但是我找不到任何关于如何在一个 TextRange 中获取两个段落的具体文档,我的代码如下
//Add title
Shape sh = slide.Shapes.AddShape(MsoAutoShapeType.msoShapeRectangle,0,0,cm(33.87f),cm(6.4f));
sh.Fill.Transparency = 1;
sh.Line.Transparency = 1;
sh.TextFrame.VerticalAnchor = MsoVerticalAnchor.msoAnchorTop;
//TextRange objText;
objText = sh.TextFrame.TextRange;
objText.Font.Name = "Microsoft JhengHei";
objText.Font.NameFarEast = "微軟正黑體";
objText.Font.Size = 48;
objText.Paragraphs(1).Lines(1).Text = "Title test\r\n";
objText.Paragraphs(1).Lines(2).Font.Color.RGB = Color.Red.ToArgb();
objText.Paragraphs(2).Lines(1).Text = "Second Paragraph";
objText.Paragraphs(2).Lines(1).Font.Color.RGB = Color.Chocolate.ToArgb();
但是我只能得到两行而不是两段的结果
- 办公室
- 2019 视觉工作室 2019
- .NET4.7
- 赢表格
解决方案
推荐阅读
- reporting-services - 如何创建将数据库名称显示为下拉过滤器的 ssrs 报告,用户可以动态选择数据库并运行报告
- reactjs - 使用 nextJs API 链接创建支付意图后,在 ConfirmCardPayment 上出现条带支付意图错误
- java - 如何在同一个 eclipse src 文件夹中复制和粘贴 eclipse 包
- django - Django Admin Inlines 错误“MultipleObjectsReturned at”
- android - 如何检查/检测用户在发出 API 请求时是否使用代理?
- c - C 编程语言:项目错误 - *** `./myText' 中的错误:free():无效指针:0xbffebb58 ***
- azure - 为每个环境创建 Azure 仪表板
- google-cloud-platform - 如何检查计算引擎 vm 是否以最大核心/持续涡轮频率运行?
- javascript - 通过 docker compose 将 envs 传递给 db
- ssh - 如何在不访问主机的情况下 ssh 到 KVM 来宾 VM?