VintaSoft Imaging .NET SDK 14.0: Документация для .NET разработчика
Vintasoft.Imaging.Office.OpenXml.Editor Namespace / OpenXmlDocumentChart Class
Члены типа Объект Синтаксис Example Иерархия Требования Смотрите также
В этом разделе
    Класс OpenXmlDocumentChart
    В этом разделе
    Представляет диаграмму документа Open XML.
    Объектная модель
    OpenXmlDrawingObjectProperties OpenXmlDocumentChartData Hyperlink SheetDrawingLocation OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElement OpenXmlDocumentElementCollection OpenXmlDocumentRootElement OpenXmlDocumentChart
    Синтаксис
    '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^
    
    
    Пример

    Вот пример, показывающий, как создать файл DOCX с диаграммой (в примере используется документ-шаблон).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);
        }
    }
    
    

    Иерархия наследования

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

    Требования

    Целевые платформы: .NET 8; .NET 7; .NET 6; .NET Framework 4.8, 4.7, 4.6, 4.5, 4.0, 3.5

    Смотрите также