VintaSoft Imaging .NET SDK 12.4: Documentation for .NET developer
Vintasoft.Imaging.Office.OpenXml.Editor Namespace / OpenXmlDocumentChart Class
Members Object Syntax Example Hierarchy Requirements SeeAlso
In This Topic
    OpenXmlDocumentChart Class
    In This Topic
    Represents a chart of Open XML document.
    Object Model
    OpenXmlDrawingObjectProperties OpenXmlDocumentChartData Hyperlink SheetDrawingLocation OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElementCollection OpenXmlDocumentRootElement OpenXmlDocumentChart
    Syntax
    'Declaration
    
    <DefaultMemberAttribute("Item")>
    Public Class OpenXmlDocumentChart
       Inherits OpenXmlDocumentGraphics
    
    
    [DefaultMember("Item")]
    public class OpenXmlDocumentChart : OpenXmlDocumentGraphics
    
    
    [DefaultMember("Item")]
    public __gc class OpenXmlDocumentChart : public OpenXmlDocumentGraphics*
    
    
    [DefaultMember("Item")]
    public ref class OpenXmlDocumentChart : public OpenXmlDocumentGraphics^
    
    
    Example

    Here is an example that shows how to create DOCX file with chart (example uses template document Chart.docx):

    
    ''' <summary>
    ''' Creates the DOCX document with chart.
    ''' </summary>
    ''' <param name="resultFilePath">The result file path.</param>
    Public Shared Sub CreateDocxWithChart(resultFilePath As String)
        ' path to a template DOCX document with chart
        Dim templateDocDocumentPath As String = "Chart.docx"
    
        ' create DOCX document editor on template document with chart
        Using docxDocumentEditor As New Vintasoft.Imaging.Office.OpenXml.Editor.Docx.DocxDocumentEditor(templateDocDocumentPath)
            ' get chart
            Dim chart As Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentChart = docxDocumentEditor.Charts(0)
    
    
            ' change chart title
    
            ' find title
            chart.Title = "Chart Title Example. " & System.DateTime.Now.ToShortDateString()
    
    
            ' change chart data
    
            ' create the chart data
            Dim chartData As System.Nullable(Of Double)(,) = New System.Nullable(Of Double)(,) {{55, 32, 23}, {84, 48, 33}, {72, 53, 86}, {34, 82, 11}}
            ' change the chart data
            chart.ChartData.SetData(chartData)
    
    
            ' save changes
            docxDocumentEditor.Save(resultFilePath)
        End Using
    End Sub
    
    
    
    /// <summary>
    /// Creates the DOCX document with chart.
    /// </summary>
    /// <param name="resultFilePath">The result file path.</param>
    public static void CreateDocxWithChart(string resultFilePath)
    {
        // path to a template DOCX document with chart
        string templateDocDocumentPath = "Chart.docx";
    
        // create DOCX document editor on template document with chart
        using (Vintasoft.Imaging.Office.OpenXml.Editor.Docx.DocxDocumentEditor docxDocumentEditor =
            new Vintasoft.Imaging.Office.OpenXml.Editor.Docx.DocxDocumentEditor(templateDocDocumentPath))
        {
            // get chart
            Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentChart chart = docxDocumentEditor.Charts[0];
    
    
            // change chart title
    
            // find title
            chart.Title = "Chart Title Example. " + System.DateTime.Now.ToShortDateString();
    
    
            // change chart data
    
            // create the chart data
            double?[,] chartData = new double?[,] {
                 { 55, 32, 23 },
                 { 84, 48, 33 },
                 { 72, 53, 86 },
                 { 34, 82, 11 } };
            // change the chart data
            chart.ChartData.SetData(chartData);
    
    
            // save changes
            docxDocumentEditor.Save(resultFilePath);
        }
    }
    
    

    Inheritance Hierarchy

    System.Object
       Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentElement
          Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentGraphics
             Vintasoft.Imaging.Office.OpenXml.Editor.OpenXmlDocumentChart

    Requirements

    Target Platforms: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    See Also