导入 Mekko 图形图表
- Home
- 资源
- 用户手册
- thinkcell Charts:数据可视化
- 定量的图表
- 导入 Mekko 图形图表
方便地将 Mekko Graphics 图表及其数据导入 thinkcell。
将 Mekko Graphics 图表导入 thinkcell
该 Import Mekko Graphics to thinkcell 工具将 Mekko Graphics 图表转换为 thinkcell 图表。您不需要安装 Mekko Graphics 即可使用导入程序工具。
要将 Mekko Graphics 图表导入 thinkcell,请按照以下步骤操作:
- 在 PowerPoint 中,在一张幻灯片中选择一个或多个 Mekko Graphics 图表或选择包含 Mekko Graphics 图表的幻灯片。
- 在功能区上,选择 thinkcell > Elements > Tools
> Import Mekko Graphics to thinkcell 或 Insert > thinkcell > Tools
> Import Mekko Graphics to thinkcell。
选择 Import Mekko Graphics to thinkcell 后,thinkcell 会将您选择的 Mekko Graphics 图表替换为 thinkcell 图表。所有其他幻灯片内容保持不变。在您替换 Mekko Graphics 图表的每张幻灯片后, thinkcell 会插入带有原始 Mekko Graphics 图表的备份幻灯片。
您可以将大多数 Mekko Graphics 图表导入 thinkcell,但以下情况除外:
- 甘特图、浮动条形图和水平浮动条形图
- 其他 Mekko Graphics 元素,如哈维球
如果无法导入 Mekko Graphics 图表或元素, thinkcell 会显示一条消息。
导入包含数据行或列的图表
如果 Mekko Graphics 图表有数据行或列,thinkcell 会将该图表导入为带有数据表的 thinkcell 图表(请参阅 带数据表的图表)。Mekko Graphics 图表可能同时代表数据表和图表中的相同数据。thinkcell 目前不支持同时代表数据表和图表中的相同数据。如果 Mekko Graphics 图表在数据表和图表中都代表相同的数据,thinkcell 将导入不带数据表的图表。
样式和格式导入的图表
thinkcell 不会导入 Mekko Graphics 图表的样式和格式。但是,在导入 Mekko Graphics 图表后,可以在 thinkcell 中重新创建图表的样式和格式。
样式图表
当 thinkcell 导入 Mekko Graphics 图表时,导入的图表采用活动 thinkcell 样式文件的样式和格式(请参阅 设置 thinkcell 样式文件)。您可以像任何其他 thinkcell 图表一样格式化导入的图表和设置其样式(请参阅 设置图表的样式和格式)。
下图显示如何使用图表的上下文菜单将 Y 轴添加到导入的图表。
设置数字格式
Mekko Graphics 图表中的大多数数字格式不会导入 thinkcell 图表。您可以在 thinkcell 中轻松更改数字格式(请参阅 设置图表标签的格式)。
下图显示如何使用迷你工具栏将原始 Mekko Graphics 图表的货币编号格式应用到导入的图表。
我们建议您比较您的 Mekko Graphics 图表和导入的图表,以确保它们彼此一致。在原始幻灯片和备份幻灯片之间切换,以比较导入的图表并对导入的图表进行任何必要的更改。对导入的图表感到满意时,可以删除备份幻灯片。
编辑导入的图表数据
thinkcell 将数据从 Mekko Graphics 图表导入到导入图表的数据表。您可以像任何其他 thinkcell 图表一样编辑导入的图表的数据(请参阅 元素数据表简介)。
显示隐藏的系列或类别
thinkcell 从 Mekko Graphics 图表中的隐藏系列或类别导入数据,作为导入图表数据表中的隐藏行或列。要在导入的图表中显示隐藏的序列或类别,选择图表数据表中包含隐藏数据的列或行,右键单击您的选择,然后选择 Unhide。如需了解更多信息,请参阅 Microsoft Support。
自动化导入过程
在 Windows,您可以使用 thinkcell API 函数以编程方式导入 Mekko Graphics 图表到 thinkcell 或检查他们。ImportMekkoGraphicsCharts 会以 thinkcell 图表取代 Mekko Graphics 图表。GetMekkoGraphicsXML 会提取 Mekko Graphics 图表的 XML 定义。
ImportMekkoGraphicsCharts
描述
此函数取代在形状阵列中以同等 thinkcell 图表传递给它的所有 Mekko Graphics 图表。所有形状必须位于同一张幻灯片上。在修改幻灯片之前,此函数将复制一份未修改的幻灯片,并将其直接插入到修改后版本的后面。
例如,如果演示文稿未被修改,它会返回 Nothing/null,因为阵列不含任何 Mekko Graphics 图表。否则,该函数返回对未修改的幻灯片副本的引用。
VBA
签名
tcPpAddIn.ImportMekkoGraphicsCharts ( _
ashp As PowerPoint.Shape() _
) As PowerPoint.Slide
示例
要使用此示例,请将其添加到 PowerPoint 中的模块中。如需更多信息,请参阅 Visual Basic for Applications。
在演示文稿上运行 ImportAll 后,将会查阅演示文稿中的幻灯片,并以同等 thinkcell 图表取代所有可见 Mekko Graphics 图表,在对其进行修改前复制一份每张包含 Mekko Graphics 图表的幻灯片。
Option Explicit
Sub ImportAll()
' Get reference to thinkcell 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
);
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 thinkcell 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 App 的 Program.cs 中的代码替换为示例。
样本需要参考 Microsoft PowerPoint 16.0 Object Library 和 Microsoft 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();
}
}
}
需要排查问题
查看我们的知识库