导入 Mekko 图形图表

方便地将 Mekko Graphics 图表及其数据导入 think-cell

将 Mekko Graphics 图表导入 think-cell

Import Mekko Graphics to think-cell 工具将 Mekko Graphics 图表转换为 think-cell 图表。您不需要安装 Mekko Graphics 即可使用导入程序工具。

要将 Mekko Graphics 图表导入 think-cell,请按照以下步骤操作:

  1. 在 PowerPoint 中,在一张幻灯片中选择一个或多个 Mekko Graphics 图表或选择包含 Mekko Graphics 图表的幻灯片。
  2. 在功能区上,选择 think-cell > Elements > Tools Tools Menu icon > Import Mekko Graphics to think-cellInsert > think-cell > Tools Tools Menu icon > Import Mekko Graphics to think-cell

选择 Import Mekko Graphics to think-cell 后,think-cell 会将您选择的 Mekko Graphics 图表替换为 think-cell 图表。所有其他幻灯片内容保持不变。在您替换 Mekko Graphics 图表的每张幻灯片后, think-cell 会插入带有原始 Mekko Graphics 图表的备份幻灯片。

您可以将大多数 Mekko Graphics 图表导入 think-cell,但以下情况除外:

  • 甘特图、浮动条形图和水平浮动条形图
  • 其他 Mekko Graphics 元素,如哈维球

如果无法导入 Mekko Graphics 图表或元素, think-cell 会显示一条消息。

导入包含数据行或列的图表

如果 Mekko Graphics 图表有数据行或列,think-cell 会将该图表导入为带有数据表的 think-cell 图表(请参阅 带数据表的图表)。Mekko Graphics 图表可能同时代表数据表和图表中的相同数据。think-cell 目前不支持同时代表数据表和图表中的相同数据。如果 Mekko Graphics 图表在数据表和图表中都代表相同的数据,think-cell 将导入不带数据表的图表。

样式和格式导入的图表

think-cell 不会导入 Mekko Graphics 图表的样式和格式。但是,在导入 Mekko Graphics 图表后,可以在 think-cell 中重新创建图表的样式和格式。

样式图表

当 think-cell 导入 Mekko Graphics 图表时,导入的图表采用活动 think-cell 样式文件的样式和格式(请参阅 Set up think-cell style files)。您可以像任何其他 think-cell 图表一样格式化导入的图表和设置其样式(请参阅 设置图表的样式和格式)。

下图显示如何使用图表的上下文菜单将 Y 轴添加到导入的图表。

Use think-cell's context menu to add axis

设置数字格式

Mekko Graphics 图表中的大多数数字格式不会导入 think-cell 图表。您可以在 think-cell 中轻松更改数字格式(请参阅 设置图表标签的格式)。

下图显示如何使用迷你工具栏将原始 Mekko Graphics 图表的货币编号格式应用到导入的图表。

我们建议您比较您的 Mekko Graphics 图表和导入的图表,以确保它们彼此一致。在原始幻灯片和备份幻灯片之间切换,以比较导入的图表并对导入的图表进行任何必要的更改。对导入的图表感到满意时,可以删除备份幻灯片。

编辑导入的图表数据

think-cell 将数据从 Mekko Graphics 图表导入到导入图表的数据表。您可以像任何其他 think-cell 图表一样编辑导入的图表的数据(请参阅 元素数据表简介)。

显示隐藏的系列或类别

think-cell 从 Mekko Graphics 图表中的隐藏系列或类别导入数据,作为导入图表数据表中的隐藏行或列。要在导入的图表中显示隐藏的序列或类别,选择图表数据表中包含隐藏数据的列或行,右键单击您的选择,然后选择 Unhide。如需了解更多信息,请参阅 Microsoft Support

自动化导入过程

仅限 Windows

在 Windows,您可以使用 think-cell API 函数以编程方式导入 Mekko Graphics 图表到 think-cell 或检查他们。ImportMekkoGraphicsCharts 会以 think-cell 图表取代 Mekko Graphics 图表。GetMekkoGraphicsXML 会提取 Mekko Graphics 图表的 XML 定义。

ImportMekkoGraphicsCharts

描述

此函数取代在形状阵列中以同等 think-cell 图表传递给它的所有 Mekko Graphics 图表。所有形状必须位于同一张幻灯片上。在修改幻灯片之前,此函数将复制一份未修改的幻灯片,并将其直接插入到修改后版本的后面。

例如,如果演示文稿未被修改,它会返回 Nothing/null,因为阵列不含任何 Mekko Graphics 图表。否则,该函数返回对未修改的幻灯片副本的引用。

VBA

签名
tcPpAddIn.ImportMekkoGraphicsCharts ( _
    ashp As PowerPoint.Shape() _
) As PowerPoint.Slide
示例

要使用此示例,请将其添加到 PowerPoint 中的模块中。如需更多信息,请参阅 Visual Basic for Applications

在演示文稿上运行 ImportAll 后,将会查阅演示文稿中的幻灯片,并以同等 think-cell 图表取代所有可见 Mekko Graphics 图表,在对其进行修改前复制一份每张包含 Mekko Graphics 图表的幻灯片。

Option Explicit

Sub ImportAll()

    ' Get reference to think-cell Object

    Dim tcPpAddIn As Object
    Set tcPpAddIn = Application.COMAddIns("thinkcell.addin").Object

    ' Iterate over copy of original Slides to avoid
    ' iterating over copies inserted by ImportMekkoGraphicsCharts again

    Dim SlidesCopy As New Collection
    Dim Slide As PowerPoint.Slide
    For Each Slide In ActivePresentation.Slides
        SlidesCopy.Add Slide
    Next Slide
    
    For Each Slide In SlidesCopy
    
        ' Construct Array containing only visible shapes on slide
        
        Dim visibleShapes() As PowerPoint.Shape
        ReDim visibleShapes(1 To Slide.Shapes.Count)
        Dim shapeIndex As Long
        For shapeIndex = 1 To Slide.Shapes.Count
            If Slide.Shapes(shapeIndex).Visible Then
                Set visibleShapes(shapeIndex) = Slide.Shapes(shapeIndex)
            End If
        Next shapeIndex
        
        ' Pass Array to ImportMekkoGraphics and store return value
        
        Dim CopySlide As PowerPoint.Slide
        Set CopySlide = tcPpAddIn.ImportMekkoGraphicsCharts(visibleShapes)
        
        ' If Slide was modified...
        If Not CopySlide Is Nothing Then
        ' ... do things with copy of unmodified slide
        End If
    Next Slide
End Sub

C#

签名
PowerPoint.Slide tcPpAddIn.ImportMekkoGraphicsCharts(
    PowerPoint.Shape[] ashp
);
示例

要使用此示例,请在 C# PowerPoint VSTO Add-in项目模板中将此方法添加到 ThisAddIn 类。如需了解更多信息,请参阅C#加载项开发

private void ImportAll(PowerPoint.Presentation presentation)
    {
        var tcPpAddIn = presentation.Application.COMAddIns.Item("thinkcell.addin").Object;
        foreach (PowerPoint.Slide slide in presentation.Slides.Cast<PowerPoint.Slide>().ToList())
        {
            PowerPoint.Slide slideCopy = tcPpAddIn.ImportMekkoGraphicsCharts(
                slide.Shapes.Cast<PowerPoint.Shape>().ToArray()
            );
        }
    }

添加以下行到 ImportAll 方法,以便在每个打开的演示文稿上运行 ThisAddIn_Startup

Application.PresentationOpen += new PowerPoint.EApplication_PresentationOpenEventHandler(ImportAll);

GetMekkoGraphicsXML

描述

此函数将 shp 中 Mekko Graphics 图表的 XML 代码作为字符串返回。它不会修改传递给它的形状。

如果 shp 不是 Mekko Graphics 图表,则会产生 E_INVALIDARG (0x80070057) 错误。

VBA

签名
tcPpAddIn.GetMekkoGraphicsXML ( _
    shp As PowerPoint.Shape _
) As String
示例

要使用此示例,请将以下代码添加到 PowerPoint 中的模块中。如需更多信息,请参阅 Visual Basic for Applications

Option Explicit

Sub GetMekkoGraphicsXMLOfAllShapes()

    ' Get reference to think-cell Object

    Dim tcPpAddIn As Object
    Set tcPpAddIn = Application.COMAddIns("thinkcell.addin").Object

    ' Go through the slides in the presentation and
    ' output the XML of each Mekko Graphics chart on the slide
    ' to the debug console

    Dim slide As PowerPoint.slide
    For Each slide In Application.ActivePresentation.Slides
        Dim shape As PowerPoint.shape
        For Each shape In slide.Shapes
            On Error Resume Next ' skip over shapes that are not Mekko Graphics charts
            Debug.Print tcPpAddIn.GetMekkoGraphicsXML(shape)
        Next shape
    Next slide
End Sub

C#

签名
string tcPpAddIn.GetMekkoGraphicsXML(
    PowerPoint.Shape shp
);
示例

要使用此示例,请将 Console AppProgram.cs 中的代码替换为示例。

样本需要参考 Microsoft PowerPoint 16.0 Object LibraryMicrosoft Office 16.0 Object Library (有关详细信息,请参见 C#)。

运行应用程序后,将会查阅 C:\Samples\GetMekkoGraphicsXML\presentation.pptx 中的演示文稿,并将演示文稿包含的 Mekko Graphics 图表的 XML 打印到控制台。

using PowerPoint = Microsoft.Office.Interop.PowerPoint;
using Office = Microsoft.Office.Core;

namespace Sample
{
    class Program
    {
        static void Main()
        {
            var ppapp = new PowerPoint.Application();
            var presentation = ppapp.Presentations.Open(
                "C:\\Samples\\GetMekkoGraphicsXML\\presentation.pptx",
                /*ReadOnly*/Office.MsoTriState.msoTrue,
                /*Untitled*/Office.MsoTriState.msoTrue,
                /*WithWindow*/Office.MsoTriState.msoFalse
            );

            var tcPpAddIn = ppapp.COMAddIns.Item("thinkcell.addin").Object;
            foreach (PowerPoint.Slide slide in presentation.Slides)
            {
                foreach (PowerPoint.Shape shape in slide.Shapes)
                {
                    string xml = tcPpAddIn.GetMekkoGraphicsXML(shape);
                    Console.WriteLine(xml);
                }
            }

            presentation.Close();
            ppapp.Quit();
        }
    }
}