[英]C# add Title to word document chart OpenXml
I have implemented a BarChart with DocumentFormat.OpenXml.Drawing.Charts
in a Word Document.我在 Word 文档中实现了带有DocumentFormat.OpenXml.Drawing.Charts
的 BarChart。
The result is a simple Chart.结果是一个简单的图表。 I want to add a title to this Chart.我想给这个图表添加一个标题。 Allready tryed AddChartTitle() from this Post.已经从这篇文章中尝试过 AddChartTitle()。 But if I execute the resulting word file is corrupt (Word experienced an error trying to open the file...).但是,如果我执行生成的 word 文件已损坏(Word 在尝试打开文件时遇到错误...)。
Here is my Code.这是我的代码。 Thanks a lot for your help!非常感谢你的帮助!
public static WordprocessingDocument CreateBarChart(WordprocessingDocument document, Dictionary<string, int> data, Paragraph paragraphToInsert, string chartName)
{
string title = "Blaaaaaaaaaaaaaaa";// chartName;
string idOfChart = "rId" + new Random().Next(1000000);
//Dictionary<string, int> data = new Dictionary<string, int>();
//data.Add("abc", 1);
// Get MainDocumentPart of Document
MainDocumentPart mainPart = document.MainDocumentPart;
//mainPart.Document = new Document(new Body());
// Create ChartPart object in Word Document
ChartPart chartPart = mainPart.AddNewPart<ChartPart>(idOfChart);
// the root element of chartPart
SeriesText header = new SeriesText(new NumericValue() { Text = "HelpHelp" });
dc.ChartSpace chartSpace = new dc.ChartSpace();
chartSpace.Append(new dc.EditingLanguage() { Val = "en-us" });
// Create Chart
dc.Chart chart = new dc.Chart();
chart.Append(new dc.AutoTitleDeleted() { Val = false });
// Define the 3D view
dc.View3D view3D = new dc.View3D();
view3D.Append(new dc.RotateX() { Val = 30 });
view3D.Append(new dc.RotateY() { Val = 0 });
// Intiliazes a new instance of the PlotArea class
dc.PlotArea plotArea = new dc.PlotArea();
dc.BarChart barChart = plotArea.AppendChild<dc.BarChart>(new dc.BarChart(new dc.BarDirection()
{ Val = new EnumValue<dc.BarDirectionValues>(dc.BarDirectionValues.Column) },
new dc.BarGrouping() { Val = new EnumValue<dc.BarGroupingValues>(dc.BarGroupingValues.Clustered) }
));
plotArea.Append(new dc.Layout());
dc.ChartShapeProperties chartShapePros = new dc.ChartShapeProperties();
uint i = 0;
// Iterate through each key in the Dictionary collection and add the key to the chart Series
// and add the corresponding value to the chart Values.
foreach (string key in data.Keys)
{
dc.BarChartSeries barChartSeries = barChart.AppendChild<dc.BarChartSeries>(new dc.BarChartSeries(new dc.Index()
{
Val =
new UInt32Value(i)
},
new dc.Order() { Val = new UInt32Value(i) },
new dc.SeriesText(new dc.NumericValue() { Text = key })));
dc.StringLiteral strLit = barChartSeries.AppendChild<dc.CategoryAxisData>(new dc.CategoryAxisData()).AppendChild<dc.StringLiteral>(new dc.StringLiteral());
strLit.Append(new dc.PointCount() { Val = new UInt32Value(1U) });
//strLit.AppendChild<dc.StringPoint>(new dc.StringPoint() { Index = new UInt32Value(0U) }).Append(new dc.NumericValue(title));
dc.NumberLiteral numLit = barChartSeries.AppendChild<DocumentFormat.OpenXml.Drawing.Charts.Values>(
new DocumentFormat.OpenXml.Drawing.Charts.Values()).AppendChild<dc.NumberLiteral>(new dc.NumberLiteral());
numLit.Append(new dc.FormatCode("General"));
numLit.Append(new dc.PointCount() { Val = new UInt32Value(1U) });
numLit.AppendChild<dc.NumericPoint>(new dc.NumericPoint() { Index = new UInt32Value(0u) }).Append
(new dc.NumericValue(data[key].ToString()));
i++;
}
barChart.Append(new dc.AxisId() { Val = new UInt32Value(48650112u) });
barChart.Append(new dc.AxisId() { Val = new UInt32Value(48672768u) });
// Add the Category Axis.
dc.CategoryAxis catAx = plotArea.AppendChild<dc.CategoryAxis>(new dc.CategoryAxis(new dc.AxisId()
{ Val = new UInt32Value(48650112u) }, new dc.Scaling(new dc.Orientation()
{
Val = new EnumValue<DocumentFormat.
OpenXml.Drawing.Charts.OrientationValues>(DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax)
}),
new dc.AxisPosition() { Val = new EnumValue<dc.AxisPositionValues>(dc.AxisPositionValues.Bottom) },
new dc.TickLabelPosition() { Val = new EnumValue<dc.TickLabelPositionValues>(dc.TickLabelPositionValues.NextTo) },
new dc.CrossingAxis() { Val = new UInt32Value(48672768U) },
new dc.Crosses() { Val = new EnumValue<dc.CrossesValues>(dc.CrossesValues.AutoZero) },
new dc.AutoLabeled() { Val = new BooleanValue(false) }, //TODO
new dc.LabelAlignment() { Val = new EnumValue<dc.LabelAlignmentValues>(dc.LabelAlignmentValues.Center) },
new dc.LabelOffset() { Val = new UInt16Value((ushort)100) }));
// Add the Value Axis.
dc.ValueAxis valAx = plotArea.AppendChild<dc.ValueAxis>(new dc.ValueAxis(new dc.AxisId() { Val = new UInt32Value(48672768u) },
new dc.Scaling(new dc.Orientation()
{
Val = new EnumValue<DocumentFormat.OpenXml.Drawing.Charts.OrientationValues>(
DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax)
}),
new dc.AxisPosition() { Val = new EnumValue<dc.AxisPositionValues>(dc.AxisPositionValues.Left) },
new dc.MajorGridlines(),
new DocumentFormat.OpenXml.Drawing.Charts.NumberingFormat()
{
FormatCode = new StringValue("General"),
SourceLinked = new BooleanValue(true)
}, new dc.TickLabelPosition()
{
Val = new EnumValue<dc.TickLabelPositionValues>
(dc.TickLabelPositionValues.NextTo)
}, new dc.CrossingAxis() { Val = new UInt32Value(48650112U) },
new dc.Crosses() { Val = new EnumValue<dc.CrossesValues>(dc.CrossesValues.AutoZero) },
new dc.CrossBetween() { Val = new EnumValue<dc.CrossBetweenValues>(dc.CrossBetweenValues.Between) }));
// create child elements of the c:legend element
// dc.Legend legend = new dc.Legend();
// legend.Append(new dc.LegendPosition() { Val = dc.LegendPositionValues.Right });
//dc.Overlay overlay = new dc.Overlay() { Val = true };
// legend.Append(overlay);
dc.TextProperties textPros = new DocumentFormat.OpenXml.Drawing.Charts.TextProperties();
textPros.Append(new d.BodyProperties());
textPros.Append(new d.ListStyle());
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);
d.Paragraph paragraph = new d.Paragraph();
paragraph.Append(paraPros);
paragraph.Append(new d.EndParagraphRunProperties() { Language = "en-Us" });
textPros.Append(paragraph);
AddChartLabels(barChart);
//legend.Append(textPros);
// Append c:view3D, c:plotArea and c:legend elements to the end of c:chart element
chart.Append(view3D);
chart.Append(plotArea);
//chart.Append(legend);
AddChartTitle(chart, "Test!!!!!!!!!!!"); // <-----------------------------------
// Append the c:chart element to the end of c:dc.ChartSpace element
chartSpace.Append(chart);
// Create c:spPr Elements and fill the child elements of it
chartShapePros = new dc.ChartShapeProperties();
d.Outline outline = new d.Outline();
outline.Append(new d.NoFill());
chartShapePros.Append(outline);
// Append c:spPr element to the end of c:dc.ChartSpace element
chartSpace.Append(chartShapePros);
chartPart.ChartSpace = chartSpace;
// Generate content of the MainDocumentPart
GeneratePartContent(mainPart, idOfChart, paragraphToInsert);
return document;
}
My Solution (Chart with header and axis labels):我的解决方案(带有 header 和轴标签的图表):
using DocumentFormat.OpenXml.Packaging;
using C = DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml;
using C14 = DocumentFormat.OpenXml.Office2010.Drawing.Charts;
using A = DocumentFormat.OpenXml.Drawing;
using C15 = DocumentFormat.OpenXml.Office2013.Drawing.Chart;
using WP = DocumentFormat.OpenXml.Wordprocessing;
using System;
using System.Collections.Generic;
public class WordChartGenerator
{
/**
* Creates Chart for word document
* @document to insert chart
* @data diagram data --> Dictionary<ChartPartName,ChartPartValue>
* @paragraphToInsert Paragrapht to insert the chart
* @chartTitle title of chart
* @Axis1 Axis label 1
* @Axis2 Axis label 2
* @ChartTitleSize Font Size of chart title
* @AxisLabelSize Axis label Font size.
* */
public WordprocessingDocument CreateChartForWordDoc(WordprocessingDocument Document, Dictionary<string, int> Data, WP.Paragraph ParagraphToInsert, string ChartTitle, string Axis1, string Axis2, int ChartTitleSize = 12, int AxisLabelSize = 10)
{
MainDocumentPart part = Document.MainDocumentPart;
string id = "rId" + new Random().Next(1000000);
GenerateChartPart(part, id, ParagraphToInsert, Data, ChartTitle, Axis1, Axis2, ChartTitleSize,AxisLabelSize);
return Document;
}
/**
* Finalized chart generation (adds chart to paragraph)
* @mainPart to insert chart
* @paragraphToInsert Paragrapht to insert the chart
* @id uniq chart diagram
* */
public void FinalizeChart(MainDocumentPart mainPart, string id, WP.Paragraph paragraphToInsert)
{
WP.Paragraph paragraph = new WP.Paragraph() { RsidParagraphAddition = "00C75AEB", RsidRunAdditionDefault = "000F3EFF" };
if (paragraphToInsert != null)
paragraph = paragraphToInsert;
// Create a new run that has an inline drawing object
WP.Run run = new WP.Run();
WP.Drawing drawing = new WP.Drawing();
A.Wordprocessing.Inline inline = new A.Wordprocessing.Inline();
inline.Append(new A.Wordprocessing.Extent() { Cx = 5274310L, Cy = 3076575L });
A.Wordprocessing.DocProperties docPros = new A.Wordprocessing.DocProperties() { Id = (UInt32Value)1U, Name = "Chart 1" };
inline.Append(docPros);
A.Graphic g = new A.Graphic();
A.GraphicData graphicData = new A.GraphicData() { Uri = "http://schemas.openxmlformats.org/drawingml/2006/chart" };
C.ChartReference chartReference = new C.ChartReference() { Id = id }; //todo: random is not nice...
graphicData.Append(chartReference);
g.Append(graphicData);
inline.Append(g);
drawing.Append(inline);
run.Append(drawing);
paragraph.Append(run);
mainPart.Document.Body.Append(paragraph);
}
/**
* Generates an Word Chart for a Wordprocessing document.
* @mPart WordProcessing Document to insert
* @idOfChart uniq Chart Id
* @Paragraph where the diagramm has to be inserted
* @data Data to insert --> Dictionary<ChartPartName,ChartPartValue>
* @chartTitle chart title
* @axis1 first axis labeling
* @axis2 second axis labeling
* @chartTitleSize Fontsize of chart Title
* @axisLabelSize Fontsize of axis
*/
private void GenerateChartPart(MainDocumentPart mPart, string idOfChart, WP.Paragraph paragraphToInsert, Dictionary<string, int> data, string chartTitle, string axis1, string axis2, int chartTitleSize = 12, int axisLabelSize = 10)
{
ChartPart part = mPart.AddNewPart<ChartPart>(idOfChart); //custommized
C.ChartSpace chartSpace1 = new C.ChartSpace();
chartSpace1.AddNamespaceDeclaration("c", "http://schemas.openxmlformats.org/drawingml/2006/chart");
chartSpace1.AddNamespaceDeclaration("a", "http://schemas.openxmlformats.org/drawingml/2006/main");
chartSpace1.AddNamespaceDeclaration("r", "http://schemas.openxmlformats.org/officeDocument/2006/relationships");
chartSpace1.AddNamespaceDeclaration("c16r2", "http://schemas.microsoft.com/office/drawing/2015/06/chart");
C.Date1904 date19041 = new C.Date1904() { Val = false };
C.EditingLanguage editingLanguage1 = new C.EditingLanguage() { Val = "en-US" };
C.RoundedCorners roundedCorners1 = new C.RoundedCorners() { Val = true };
AlternateContent alternateContent1 = new AlternateContent();
alternateContent1.AddNamespaceDeclaration("mc", "http://schemas.openxmlformats.org/markup-compatibility/2006");
AlternateContentChoice alternateContentChoice1 = new AlternateContentChoice() { Requires = "c14" };
alternateContentChoice1.AddNamespaceDeclaration("c14", "http://schemas.microsoft.com/office/drawing/2007/8/2/chart");
C14.Style style1 = new C14.Style() { Val = 102 };
alternateContentChoice1.Append(style1);
AlternateContentFallback alternateContentFallback1 = new AlternateContentFallback();
C.Style style2 = new C.Style() { Val = 2 };
alternateContentFallback1.Append(style2);
alternateContent1.Append(alternateContentChoice1);
alternateContent1.Append(alternateContentFallback1);
C.Chart chart1 = new C.Chart();
C.Title title1 = new C.Title();
C.ChartText chartText1 = new C.ChartText();
C.RichText richText1 = new C.RichText();
A.BodyProperties bodyProperties1 = new A.BodyProperties();
A.ListStyle listStyle1 = new A.ListStyle();
A.Paragraph paragraph1 = new A.Paragraph();
A.ParagraphProperties paragraphProperties1 = new A.ParagraphProperties();
A.DefaultRunProperties defaultRunProperties1 = new A.DefaultRunProperties();
paragraphProperties1.Append(defaultRunProperties1);
A.Run run1 = new A.Run();
A.RunProperties runProperties1 = new A.RunProperties() { Language = "de-DE", FontSize = chartTitleSize*10};
A.Text text1 = new A.Text();
text1.Text = chartTitle;
run1.Append(runProperties1);
run1.Append(text1);
paragraph1.Append(paragraphProperties1);
paragraph1.Append(run1);
richText1.Append(bodyProperties1);
richText1.Append(listStyle1);
richText1.Append(paragraph1);
chartText1.Append(richText1);
C.Overlay overlay1 = new C.Overlay() { Val = false };
title1.Append(chartText1);
title1.Append(overlay1);
C.AutoTitleDeleted autoTitleDeleted1 = new C.AutoTitleDeleted() { Val = false };
C.PlotArea plotArea1 = new C.PlotArea();
C.Layout layout1 = new C.Layout();
List<C.BarChartSeries> charts = new List<C.BarChartSeries>();
C.BarChart barChart1 = new C.BarChart();
C.BarDirection barDirection1 = new C.BarDirection() { Val = C.BarDirectionValues.Column };
C.BarGrouping barGrouping1 = new C.BarGrouping() { Val = C.BarGroupingValues.Clustered };
C.VaryColors varyColors1 = new C.VaryColors() { Val = true };
int i = 0;
foreach (string key in data.Keys)
{
C.BarChartSeries barChartSeries1 = new C.BarChartSeries();
C.Index index1 = new C.Index() { Val = Convert.ToUInt32(i) };
C.Order order1 = new C.Order() { Val = Convert.ToUInt32(i) };
C.SeriesText seriesText1 = new C.SeriesText();
C.NumericValue numericValue1 = new C.NumericValue();
numericValue1.Text = key;
seriesText1.Append(numericValue1);
C.InvertIfNegative invertIfNegative1 = new C.InvertIfNegative() { Val = true };
C.DataLabels dataLabels1 = new C.DataLabels();
C.ChartShapeProperties chartShapeProperties1 = new C.ChartShapeProperties();
A.NoFill noFill1 = new A.NoFill();
A.Outline outline1 = new A.Outline();
A.NoFill noFill2 = new A.NoFill();
outline1.Append(noFill2);
A.EffectList effectList1 = new A.EffectList();
chartShapeProperties1.Append(noFill1);
chartShapeProperties1.Append(outline1);
chartShapeProperties1.Append(effectList1);
C.ShowLegendKey showLegendKey1 = new C.ShowLegendKey() { Val = true };
C.ShowValue showValue1 = new C.ShowValue() { Val = true };
C.ShowCategoryName showCategoryName1 = new C.ShowCategoryName() { Val = false };
C.ShowSeriesName showSeriesName1 = new C.ShowSeriesName() { Val = true };
C.ShowPercent showPercent1 = new C.ShowPercent() { Val = false };
C.ShowBubbleSize showBubbleSize1 = new C.ShowBubbleSize() { Val = false };
C.ShowLeaderLines showLeaderLines1 = new C.ShowLeaderLines() { Val = false };
C.DLblsExtensionList dLblsExtensionList1 = new C.DLblsExtensionList();
C.DLblsExtension dLblsExtension1 = new C.DLblsExtension() { Uri = "{CE6537A1-D6FC-4f65-9D91-7224C49458BB}" };
dLblsExtension1.AddNamespaceDeclaration("c15", "http://schemas.microsoft.com/office/drawing/2012/chart");
C15.ShowLeaderLines showLeaderLines2 = new C15.ShowLeaderLines() { Val = false };
dLblsExtension1.Append(showLeaderLines2);
dLblsExtensionList1.Append(dLblsExtension1);
dataLabels1.Append(chartShapeProperties1);
dataLabels1.Append(showLegendKey1);
dataLabels1.Append(showValue1);
dataLabels1.Append(showCategoryName1);
dataLabels1.Append(showSeriesName1);
dataLabels1.Append(showPercent1);
dataLabels1.Append(showBubbleSize1);
dataLabels1.Append(showLeaderLines1);
dataLabels1.Append(dLblsExtensionList1);
C.CategoryAxisData categoryAxisData1 = new C.CategoryAxisData();
C.StringLiteral stringLiteral1 = new C.StringLiteral();
C.PointCount pointCount1 = new C.PointCount() { Val = (UInt32Value)1U };
stringLiteral1.Append(pointCount1);
categoryAxisData1.Append(stringLiteral1);
C.Values values1 = new C.Values();
C.NumberLiteral numberLiteral1 = new C.NumberLiteral();
C.FormatCode formatCode1 = new C.FormatCode();
formatCode1.Text = "General";
C.PointCount pointCount2 = new C.PointCount() { Val = (UInt32Value)1U };
C.NumericPoint numericPoint1 = new C.NumericPoint() { Index = (UInt32Value)0U };
C.NumericValue numericValue2 = new C.NumericValue();
numericValue2.Text = data[key].ToString();
numericPoint1.Append(numericValue2);
numberLiteral1.Append(formatCode1);
numberLiteral1.Append(pointCount2);
numberLiteral1.Append(numericPoint1);
values1.Append(numberLiteral1);
C.BarSerExtensionList barSerExtensionList1 = new C.BarSerExtensionList();
C.BarSerExtension barSerExtension1 = new C.BarSerExtension() { Uri = "{C3380CC4-5D6E-409C-BE32-E72D297353CC}" };
barSerExtension1.AddNamespaceDeclaration("c16", "http://schemas.microsoft.com/office/drawing/2014/chart");
OpenXmlUnknownElement openXmlUnknownElement1 = OpenXmlUnknownElement.CreateOpenXmlUnknownElement("<c16:uniqueId val=\"{" + i.ToString().PadLeft(8, '0') + "-3253-4028-997C-A2631CC5E43E}\" xmlns:c16=\"http://schemas.microsoft.com/office/drawing/2014/chart\" />");
barSerExtension1.Append(openXmlUnknownElement1);
barSerExtensionList1.Append(barSerExtension1);
barChartSeries1.Append(index1);
barChartSeries1.Append(order1);
barChartSeries1.Append(seriesText1);
barChartSeries1.Append(invertIfNegative1);
barChartSeries1.Append(dataLabels1);
barChartSeries1.Append(categoryAxisData1);
barChartSeries1.Append(values1);
barChartSeries1.Append(barSerExtensionList1);
charts.Add(barChartSeries1);
barChart1.Append(barChartSeries1);
i++;
}
C.DataLabels dataLabels4 = new C.DataLabels();
C.ShowLegendKey showLegendKey4 = new C.ShowLegendKey() { Val = true };
C.ShowValue showValue4 = new C.ShowValue() { Val = true };
C.ShowCategoryName showCategoryName4 = new C.ShowCategoryName() { Val = false };
C.ShowSeriesName showSeriesName4 = new C.ShowSeriesName() { Val = true };
C.ShowPercent showPercent4 = new C.ShowPercent() { Val = false };
C.ShowBubbleSize showBubbleSize4 = new C.ShowBubbleSize() { Val = false };
dataLabels4.Append(showLegendKey4);
dataLabels4.Append(showValue4);
dataLabels4.Append(showCategoryName4);
dataLabels4.Append(showSeriesName4);
dataLabels4.Append(showPercent4);
dataLabels4.Append(showBubbleSize4);
C.GapWidth gapWidth1 = new C.GapWidth() { Val = (UInt16Value)150U };
C.AxisId axisId1 = new C.AxisId() { Val = (UInt32Value)48650112U };
C.AxisId axisId2 = new C.AxisId() { Val = (UInt32Value)48672768U };
barChart1.Append(barDirection1);
barChart1.Append(barGrouping1);
barChart1.Append(varyColors1);
/*foreach(C.BarChartSeries chart in charts){
barChart1.Append(chart);
}*/
barChart1.Append(dataLabels4);
barChart1.Append(gapWidth1);
barChart1.Append(axisId1);
barChart1.Append(axisId2);
C.CategoryAxis categoryAxis1 = new C.CategoryAxis();
C.AxisId axisId3 = new C.AxisId() { Val = (UInt32Value)48650112U };
C.Scaling scaling1 = new C.Scaling();
C.Orientation orientation1 = new C.Orientation() { Val = C.OrientationValues.MinMax };
scaling1.Append(orientation1);
C.Delete delete1 = new C.Delete() { Val = true };
C.AxisPosition axisPosition1 = new C.AxisPosition() { Val = C.AxisPositionValues.Bottom };
C.Title title2 = new C.Title();
C.ChartText chartText2 = new C.ChartText();
C.RichText richText2 = new C.RichText();
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();
paragraphProperties2.Append(defaultRunProperties2);
A.Run run2 = new A.Run();
A.RunProperties runProperties2 = new A.RunProperties() { Language = "de-DE", FontSize = axisLabelSize*10 };
A.Text text2 = new A.Text();
text2.Text = axis2;
run2.Append(runProperties2);
run2.Append(text2);
paragraph2.Append(paragraphProperties2);
paragraph2.Append(run2);
richText2.Append(bodyProperties2);
richText2.Append(listStyle2);
richText2.Append(paragraph2);
chartText2.Append(richText2);
C.Overlay overlay2 = new C.Overlay() { Val = false };
title2.Append(chartText2);
title2.Append(overlay2);
C.NumberingFormat numberingFormat1 = new C.NumberingFormat() { FormatCode = "General", SourceLinked = false };
C.MajorTickMark majorTickMark1 = new C.MajorTickMark() { Val = C.TickMarkValues.Cross };
C.MinorTickMark minorTickMark1 = new C.MinorTickMark() { Val = C.TickMarkValues.Cross };
C.TickLabelPosition tickLabelPosition1 = new C.TickLabelPosition() { Val = C.TickLabelPositionValues.NextTo };
C.CrossingAxis crossingAxis1 = new C.CrossingAxis() { Val = (UInt32Value)48672768U };
C.Crosses crosses1 = new C.Crosses() { Val = C.CrossesValues.AutoZero };
C.AutoLabeled autoLabeled1 = new C.AutoLabeled() { Val = false };
C.LabelAlignment labelAlignment1 = new C.LabelAlignment() { Val = C.LabelAlignmentValues.Center };
C.LabelOffset labelOffset1 = new C.LabelOffset() { Val = (UInt16Value)100U };
C.NoMultiLevelLabels noMultiLevelLabels1 = new C.NoMultiLevelLabels() { Val = true };
categoryAxis1.Append(axisId3);
categoryAxis1.Append(scaling1);
categoryAxis1.Append(delete1);
categoryAxis1.Append(axisPosition1);
categoryAxis1.Append(title2);
categoryAxis1.Append(numberingFormat1);
categoryAxis1.Append(majorTickMark1);
categoryAxis1.Append(minorTickMark1);
categoryAxis1.Append(tickLabelPosition1);
categoryAxis1.Append(crossingAxis1);
categoryAxis1.Append(crosses1);
categoryAxis1.Append(autoLabeled1);
categoryAxis1.Append(labelAlignment1);
categoryAxis1.Append(labelOffset1);
categoryAxis1.Append(noMultiLevelLabels1);
C.ValueAxis valueAxis1 = new C.ValueAxis();
C.AxisId axisId4 = new C.AxisId() { Val = (UInt32Value)48672768U };
C.Scaling scaling2 = new C.Scaling();
C.Orientation orientation2 = new C.Orientation() { Val = C.OrientationValues.MinMax };
scaling2.Append(orientation2);
C.Delete delete2 = new C.Delete() { Val = true };
C.AxisPosition axisPosition2 = new C.AxisPosition() { Val = C.AxisPositionValues.Left };
C.MajorGridlines majorGridlines1 = new C.MajorGridlines();
C.Title title3 = new C.Title();
C.ChartText chartText3 = new C.ChartText();
C.RichText richText3 = new C.RichText();
A.BodyProperties bodyProperties3 = new A.BodyProperties();
A.ListStyle listStyle3 = new A.ListStyle();
A.Paragraph paragraph3 = new A.Paragraph();
A.ParagraphProperties paragraphProperties3 = new A.ParagraphProperties();
A.DefaultRunProperties defaultRunProperties3 = new A.DefaultRunProperties();
paragraphProperties3.Append(defaultRunProperties3);
A.Run run3 = new A.Run();
A.RunProperties runProperties3 = new A.RunProperties() { Language = "de-DE", FontSize = axisLabelSize * 10 };
A.Text text3 = new A.Text();
text3.Text = axis1;
run3.Append(runProperties3);
run3.Append(text3);
paragraph3.Append(paragraphProperties3);
paragraph3.Append(run3);
richText3.Append(bodyProperties3);
richText3.Append(listStyle3);
richText3.Append(paragraph3);
chartText3.Append(richText3);
C.Overlay overlay3 = new C.Overlay() { Val = false };
title3.Append(chartText3);
title3.Append(overlay3);
C.NumberingFormat numberingFormat2 = new C.NumberingFormat() { FormatCode = "General", SourceLinked = true };
C.MajorTickMark majorTickMark2 = new C.MajorTickMark() { Val = C.TickMarkValues.Cross };
C.MinorTickMark minorTickMark2 = new C.MinorTickMark() { Val = C.TickMarkValues.Cross };
C.TickLabelPosition tickLabelPosition2 = new C.TickLabelPosition() { Val = C.TickLabelPositionValues.NextTo };
C.CrossingAxis crossingAxis2 = new C.CrossingAxis() { Val = (UInt32Value)48650112U };
C.Crosses crosses2 = new C.Crosses() { Val = C.CrossesValues.AutoZero };
C.CrossBetween crossBetween1 = new C.CrossBetween() { Val = C.CrossBetweenValues.Between };
valueAxis1.Append(axisId4);
valueAxis1.Append(scaling2);
valueAxis1.Append(delete2);
valueAxis1.Append(axisPosition2);
valueAxis1.Append(majorGridlines1);
valueAxis1.Append(title3);
valueAxis1.Append(numberingFormat2);
valueAxis1.Append(majorTickMark2);
valueAxis1.Append(minorTickMark2);
valueAxis1.Append(tickLabelPosition2);
valueAxis1.Append(crossingAxis2);
valueAxis1.Append(crosses2);
valueAxis1.Append(crossBetween1);
plotArea1.Append(layout1);
plotArea1.Append(barChart1);
plotArea1.Append(categoryAxis1);
plotArea1.Append(valueAxis1);
C.PlotVisibleOnly plotVisibleOnly1 = new C.PlotVisibleOnly() { Val = true };
C.DisplayBlanksAs displayBlanksAs1 = new C.DisplayBlanksAs() { Val = C.DisplayBlanksAsValues.Zero };
C.ShowDataLabelsOverMaximum showDataLabelsOverMaximum1 = new C.ShowDataLabelsOverMaximum() { Val = true };
chart1.Append(title1);
chart1.Append(autoTitleDeleted1);
chart1.Append(plotArea1);
chart1.Append(plotVisibleOnly1);
chart1.Append(displayBlanksAs1);
chart1.Append(showDataLabelsOverMaximum1);
C.ShapeProperties shapeProperties1 = new C.ShapeProperties();
A.Outline outline4 = new A.Outline();
A.NoFill noFill7 = new A.NoFill();
outline4.Append(noFill7);
shapeProperties1.Append(outline4);
chartSpace1.Append(date19041);
chartSpace1.Append(editingLanguage1);
chartSpace1.Append(roundedCorners1);
chartSpace1.Append(alternateContent1);
chartSpace1.Append(chart1);
chartSpace1.Append(shapeProperties1);
part.ChartSpace = chartSpace1;
FinalizeChart(mPart, idOfChart, paragraphToInsert);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.