我正在尝试使用互操作 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
- 赢表格