Ниже приведена часть сценария, который помог мне создать гистограмму в превосходить.
Код: Выделить всё
// Add a new drawing to the worksheet.
DrawingsPart drawingsPart = worksheetPart.AddNewPart();
worksheetPart.Worksheet.Append(new DocumentFormat.OpenXml.Spreadsheet.Drawing() { Id = worksheetPart.GetIdOfPart(drawingsPart) });
worksheetPart.Worksheet.Save();
// Add a new chart and set the chart language to English-US.
ChartPart chartPart = drawingsPart.AddNewPart();
chartPart.ChartSpace = new ChartSpace();
chartPart.ChartSpace.Append(new EditingLanguage() { Val = new StringValue("en-US") });
Drawing.Charts.Chart chart = chartPart.ChartSpace.AppendChild(new Drawing.Charts.Chart());
addChartTitle(chart, chartTitleText);
// Create a new clustered column chart.
PlotArea plotArea = chart.AppendChild
(new PlotArea());
Layout layout = plotArea.AppendChild(new Layout());
addBarchart(plotArea);
addCategoryAxis(plotArea);
// Add the Value Axis.
ValueAxis valAx = plotArea.AppendChild(new ValueAxis(new AxisId() { Val = new UInt32Value(48672768u) },
new Scaling(new Orientation() { Val = new EnumValue(DocumentFormat.OpenXml.Drawing.Charts.OrientationValues.MinMax) }),
new AxisPosition() { Val = new EnumValue(AxisPositionValues.Left) }, new MajorGridlines(), new DocumentFormat.OpenXml.Drawing.Charts.NumberingFormat()
{ FormatCode = new StringValue("General"), SourceLinked = new BooleanValue(true) }, new TickLabelPosition() { Val = new EnumValue (TickLabelPositionValues.NextTo) },
new CrossingAxis() { Val = new UInt32Value(48650112U) }, new Crosses() { Val = new EnumValue(CrossesValues.AutoZero) }, new CrossBetween() { Val = new EnumValue(CrossBetweenValues.Between) }));
Подробнее здесь: https://stackoverflow.com/questions/433 ... n-open-xml
Мобильная версия