首页 > 解决方案 > 如何在 c# 中使用 openxml 生成的 word 文档中减小文本的字体大小或间距

问题描述

我正在使用 openxml 成功生成一个 word 文档。我的 Word 文档包含一个饼图和文本。现在的问题是由于高度较低,Legends 中的最后一行被隐藏了,我只有 3 个选项我无法做到。

我尝试了以下场景

这是代码:

public void CreateChart(List<ChartSubArea> chartList, string variable, string id)
    {

    dc.Legend legend2 = new dc.Legend();
    dc.LegendPosition legendPosition2 = new dc.LegendPosition() 
         { val = dc.LegendPositionValues.Right };
    dc.Overlay overlay3 = new dc.Overlay() { Val = false };
    legend2.Append(legendPosition2);
    legend2.Append(overlay3);

    dc.TextProperties textPros = new TextProperties();
    textPros.Append(new d.BodyProperties());
    textPros.Append(new d.ListStyle());

    d.Paragraph paragraph = new d.Paragraph();
    d.ParagraphProperties paraPros = new d.ParagraphProperties();
    d.DefaultParagraphProperties defaultParaPros = new d.DefaultParagraphProperties();
    defaultParaPros.Append(new d.LatinFont() { Typeface = "Arial", PitchFamily = 34, CharacterSet = 0 });
    defaultParaPros.Append(new d.ComplexScriptFont() { Typeface = "Arial", PitchFamily = 34, CharacterSet = 0 });
    paraPros.Append(defaultParaPros);
    paragraph.Append(paraPros);
    paragraph.Append(new d.EndParagraphRunProperties() { Language = "en-Us" });

    textPros.Append(paragraph);

 }

标签: c#asp.netchartsms-wordopenxml-sdk

解决方案


推荐阅读