C# 在c中打开的xml图表上显示数据标签#

C# 在c中打开的xml图表上显示数据标签#,c#,xml,asp.net-mvc,model-view-controller,C#,Xml,Asp.net Mvc,Model View Controller,我们使用开放xml在exl导出中显示条形图,但它不显示数据上的标签,如每个条形图上方的值。 这是我正在使用的代码 BarChart barChart = plotArea.AppendChild<BarChart>(new BarChart(new BarDirection() { Val = new EnumValue<BarDirectionValues>(BarDirectionValues.Column) }, ne

我们使用开放xml在exl导出中显示条形图,但它不显示数据上的标签,如每个条形图上方的值。 这是我正在使用的代码

BarChart barChart = plotArea.AppendChild<BarChart>(new BarChart(new BarDirection() { Val = new         EnumValue<BarDirectionValues>(BarDirectionValues.Column) },
                new BarGrouping() { Val = new EnumValue<BarGroupingValues>(BarGroupingValues.Clustered) }));
BarChartSeries barChartSeries = barChart.AppendChild<BarChartSeries>(new BarChartSeries(new Index()
                {
                    Val =
                        new UInt32Value(i)
                },
                    new Order() { Val = new UInt32Value(i) },
                    new SeriesText(new NumericValue() { Text = key })));
BarChart BarChart=plotArea.AppendChild(新的BarChart(新的BarDirection(){Val=new EnumValue(BarDirectionValues.Column)},
new BarGrouping(){Val=new EnumValue(BarGroupingValues.Clustered)});
BarChartSeries BarChartSeries=barChart.AppendChild(新的BarChartSeries(新的索引)()
{
瓦尔=
新UINT32值(一)
},
新顺序(){Val=new uint32值(i)},
新的序列文本(newnumericvalue(){Text=key}));

其中key是条的数据值。但它仍然没有显示出来。有人能告诉我们应该在哪里放置数据标签,以便在条形图中的每个条形顶部都可以看到值标签吗?您只需要创建一个DataLabels类,修改它们的外观并将其附加到序列中。希望这有帮助

        C.DataLabels dataLabels2 = new C.DataLabels();

        C.TextProperties textProperties2 = new C.TextProperties();
        A.BodyProperties bodyProperties2 = new A.BodyProperties();
        A.ListStyle listStyle2 = new A.ListStyle();

        A.Paragraph paragraph2 = new A.Paragraph();

        A.ParagraphProperties paragraphProperties2 = new A.ParagraphProperties();

        A.DefaultRunProperties defaultRunProperties2 = new A.DefaultRunProperties() { FontSize = 700 };

        A.SolidFill solidFill2 = new A.SolidFill();
        A.SchemeColor schemeColor2 = new A.SchemeColor() { Val = A.SchemeColorValues.Background1 };

        solidFill2.Append(schemeColor2);

        defaultRunProperties2.Append(solidFill2);

        paragraphProperties2.Append(defaultRunProperties2);
        A.EndParagraphRunProperties endParagraphRunProperties2 = new A.EndParagraphRunProperties() { Language = "en-US" };

        paragraph2.Append(paragraphProperties2);
        paragraph2.Append(endParagraphRunProperties2);

        textProperties2.Append(bodyProperties2);
        textProperties2.Append(listStyle2);
        textProperties2.Append(paragraph2);
        C.ShowLegendKey showLegendKey2 = new C.ShowLegendKey() { Val = false };
        C.ShowValue showValue2 = new C.ShowValue() { Val = true };
        C.ShowCategoryName showCategoryName2 = new C.ShowCategoryName() { Val = false };
        C.ShowSeriesName showSeriesName2 = new C.ShowSeriesName() { Val = false };
        C.ShowPercent showPercent2 = new C.ShowPercent() { Val = false };
        C.ShowBubbleSize showBubbleSize2 = new C.ShowBubbleSize() { Val = false };
        C.ShowLeaderLines showLeaderLines2 = new C.ShowLeaderLines() { Val = false };

        dataLabels2.Append(textProperties2);
        dataLabels2.Append(showLegendKey2);
        dataLabels2.Append(showValue2);
        dataLabels2.Append(showCategoryName2);
        dataLabels2.Append(showSeriesName2);
        dataLabels2.Append(showPercent2);
        dataLabels2.Append(showBubbleSize2);
        dataLabels2.Append(showLeaderLines2);


        barChartSeries2.Append(dataLabels2);