如何使用Office Js插入一个瀑布图?

问题描述 投票:0回答:1

我有这段代码,在MS Word文档中使用Office Js在内容控件中插入一个图表。

Word.run(function (context) {
    var mySelection = context.document.getSelection();
    var contentCtrl = mySelection.insertContentControl();
    contentCtrl.insertOoxml(Ooxml, "start");
    return context.sync().then(function () {
       console.log("Success!");
    }).catch(errorHandler);
}).catch(errorHandler);

而且它与标准的图表配合得很好。例如一个聚类列图,其内容如下图所示 Ooxml:

<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
    <pkg:part pkg:name="/word/charts/chart1.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.drawingml.chart+xml">
        <pkg:xmlData>
            <c:chartSpace xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:c16r2="http://schemas.microsoft.com/office/drawing/2015/06/chart">
                <c:date1904 val="0"/>
                <c:lang val="en-US"/>
                <c:roundedCorners val="0"/>
                <mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
                    <mc:Choice Requires="c14" xmlns:c14="http://schemas.microsoft.com/office/drawing/2007/8/2/chart">
                        <c14:style val="102"/>
                    </mc:Choice>
                    <mc:Fallback>
                        <c:style val="2"/>
                    </mc:Fallback>
                </mc:AlternateContent>
                <c:chart>
                    <c:title>
                        <c:overlay val="0"/>
                        <c:spPr>
                            <a:noFill/>
                            <a:ln>
                                <a:noFill/>
                            </a:ln>
                            <a:effectLst/>
                        </c:spPr>
                        <c:txPr>
                            <a:bodyPr rot="0" spcFirstLastPara="1" vertOverflow="ellipsis" vert="horz" wrap="square" anchor="ctr" anchorCtr="1"/>
                            <a:lstStyle/>
                            <a:p>
                                <a:pPr>
                                    <a:defRPr sz="1400" b="0" i="0" u="none" strike="noStrike" kern="1200" spc="0" baseline="0">
                                        <a:solidFill>
                                            <a:schemeClr val="tx1">
                                                <a:lumMod val="65000"/>
                                                <a:lumOff val="35000"/>
                                            </a:schemeClr>
                                        </a:solidFill>
                                        <a:latin typeface="+mn-lt"/>
                                        <a:ea typeface="+mn-ea"/>
                                        <a:cs typeface="+mn-cs"/>
                                    </a:defRPr>
                                </a:pPr>
                                <a:endParaRPr lang="it-IT"/>
                            </a:p>
                        </c:txPr>
                    </c:title>
                    <c:autoTitleDeleted val="0"/>
                    <c:plotArea>
                        <c:layout/>
                        <c:barChart>
                            <c:barDir val="col"/>
                            <c:grouping val="clustered"/>
                            <c:varyColors val="0"/>
                            <c:ser>
                                <c:idx val="0"/>
                                <c:order val="0"/>
                                <c:tx>
                                    <c:strRef>
                                        <c:f>Sheet1!$B$1</c:f>
                                        <c:strCache>
                                            <c:ptCount val="1"/>
                                            <c:pt idx="0">
                                                <c:v>Series 1</c:v>
                                            </c:pt>
                                        </c:strCache>
                                    </c:strRef>
                                </c:tx>
                                <c:spPr>
                                    <a:solidFill>
                                        <a:schemeClr val="accent1"/>
                                    </a:solidFill>
                                    <a:ln>
                                        <a:noFill/>
                                    </a:ln>
                                    <a:effectLst/>
                                </c:spPr>
                                <c:invertIfNegative val="0"/>
                                <c:cat>
                                    <c:strRef>
                                        <c:f>Sheet1!$A$2:$A$5</c:f>
                                        <c:strCache>
                                            <c:ptCount val="4"/>
                                            <c:pt idx="0">
                                                <c:v>Category 1</c:v>
                                            </c:pt>
                                            <c:pt idx="1">
                                                <c:v>Category 2</c:v>
                                            </c:pt>
                                            <c:pt idx="2">
                                                <c:v>Category 3</c:v>
                                            </c:pt>
                                            <c:pt idx="3">
                                                <c:v>Category 4</c:v>
                                            </c:pt>
                                        </c:strCache>
                                    </c:strRef>
                                </c:cat>
                                <c:val>
                                    <c:numRef>
                                        <c:f>Sheet1!$B$2:$B$5</c:f>
                                        <c:numCache>
                                            <c:formatCode>General</c:formatCode>
                                            <c:ptCount val="4"/>
                                            <c:pt idx="0">
                                                <c:v>4.3</c:v>
                                            </c:pt>
                                            <c:pt idx="1">
                                                <c:v>2.5</c:v>
                                            </c:pt>
                                            <c:pt idx="2">
                                                <c:v>3.5</c:v>
                                            </c:pt>
                                            <c:pt idx="3">
                                                <c:v>4.5</c:v>
                                            </c:pt>
                                        </c:numCache>
                                    </c:numRef>
                                </c:val>
                                <c:extLst>
                                    <c:ext uri="{C3380CC4-5D6E-409C-BE32-E72D297353CC}" xmlns:c16="http://schemas.microsoft.com/office/drawing/2014/chart">
                                        <c16:uniqueId val="{00000000-8503-47A1-94D3-B89DD2A1A99D}"/>
                                    </c:ext>
                                </c:extLst>
                            </c:ser>
                            <c:ser>
                                <c:idx val="1"/>
                                <c:order val="1"/>
                                <c:tx>
                                    <c:strRef>
                                        <c:f>Sheet1!$C$1</c:f>
                                        <c:strCache>
                                            <c:ptCount val="1"/>
                                            <c:pt idx="0">
                                                <c:v>Series 2</c:v>
                                            </c:pt>
                                        </c:strCache>
                                    </c:strRef>
                                </c:tx>
                                <c:spPr>
                                    <a:solidFill>
                                        <a:schemeClr val="accent2"/>
                                    </a:solidFill>
                                    <a:ln>
                                        <a:noFill/>
                                    </a:ln>
                                    <a:effectLst/>
                                </c:spPr>
                                <c:invertIfNegative val="0"/>
                                <c:cat>
                                    <c:strRef>
                                        <c:f>Sheet1!$A$2:$A$5</c:f>
                                        <c:strCache>
                                            <c:ptCount val="4"/>
                                            <c:pt idx="0">
                                                <c:v>Category 1</c:v>
                                            </c:pt>
                                            <c:pt idx="1">
                                                <c:v>Category 2</c:v>
                                            </c:pt>
                                            <c:pt idx="2">
                                                <c:v>Category 3</c:v>
                                            </c:pt>
                                            <c:pt idx="3">
                                                <c:v>Category 4</c:v>
                                            </c:pt>
                                        </c:strCache>
                                    </c:strRef>
                                </c:cat>
                                <c:val>
                                    <c:numRef>
                                        <c:f>Sheet1!$C$2:$C$5</c:f>
                                        <c:numCache>
                                            <c:formatCode>General</c:formatCode>
                                            <c:ptCount val="4"/>
                                            <c:pt idx="0">
                                                <c:v>2.4</c:v>
                                            </c:pt>
                                            <c:pt idx="1">
                                                <c:v>4.4000000000000004</c:v>
                                            </c:pt>
                                            <c:pt idx="2">
                                                <c:v>1.8</c:v>
                                            </c:pt>
                                            <c:pt idx="3">
                                                <c:v>2.8</c:v>
                                            </c:pt>
                                        </c:numCache>
                                    </c:numRef>
                                </c:val>
                                <c:extLst>
                                    <c:ext uri="{C3380CC4-5D6E-409C-BE32-E72D297353CC}" xmlns:c16="http://schemas.microsoft.com/office/drawing/2014/chart">
                                        <c16:uniqueId val="{00000001-8503-47A1-94D3-B89DD2A1A99D}"/>
                                    </c:ext>
                                </c:extLst>
                            </c:ser>
                            <c:ser>
                                <c:idx val="2"/>
                                <c:order val="2"/>
                                <c:tx>
                                    <c:strRef>
                                        <c:f>Sheet1!$D$1</c:f>
                                        <c:strCache>
                                            <c:ptCount val="1"/>
                                            <c:pt idx="0">
                                                <c:v>Series 3</c:v>
                                            </c:pt>
                                        </c:strCache>
                                    </c:strRef>
                                </c:tx>
                                <c:spPr>
                                    <a:solidFill>
                                        <a:schemeClr val="accent3"/>
                                    </a:solidFill>
                                    <a:ln>
                                        <a:noFill/>
                                    </a:ln>
                                    <a:effectLst/>
                                </c:spPr>
                                <c:invertIfNegative val="0"/>
                                <c:cat>
                                    <c:strRef>
                                        <c:f>Sheet1!$A$2:$A$5</c:f>
                                        <c:strCache>
                                            <c:ptCount val="4"/>
                                            <c:pt idx="0">
                                                <c:v>Category 1</c:v>
                                            </c:pt>
                                            <c:pt idx="1">
                                                <c:v>Category 2</c:v>
                                            </c:pt>
                                            <c:pt idx="2">
                                                <c:v>Category 3</c:v>
                                            </c:pt>
                                            <c:pt idx="3">
                                                <c:v>Category 4</c:v>
                                            </c:pt>
                                        </c:strCache>
                                    </c:strRef>
                                </c:cat>
                                <c:val>
                                    <c:numRef>
                                        <c:f>Sheet1!$D$2:$D$5</c:f>
                                        <c:numCache>
                                            <c:formatCode>General</c:formatCode>
                                            <c:ptCount val="4"/>
                                            <c:pt idx="0">
                                                <c:v>2</c:v>
                                            </c:pt>
                                            <c:pt idx="1">
                                                <c:v>2</c:v>
                                            </c:pt>
                                            <c:pt idx="2">
                                                <c:v>3</c:v>
                                            </c:pt>
                                            <c:pt idx="3">
                                                <c:v>5</c:v>
                                            </c:pt>
                                        </c:numCache>
                                    </c:numRef>
                                </c:val>
                                <c:extLst>
                                    <c:ext uri="{C3380CC4-5D6E-409C-BE32-E72D297353CC}" xmlns:c16="http://schemas.microsoft.com/office/drawing/2014/chart">
                                        <c16:uniqueId val="{00000002-8503-47A1-94D3-B89DD2A1A99D}"/>
                                    </c:ext>
                                </c:extLst>
                            </c:ser>
                            <c:dLbls>
                                <c:showLegendKey val="0"/>
                                <c:showVal val="0"/>
                                <c:showCatName val="0"/>
                                <c:showSerName val="0"/>
                                <c:showPercent val="0"/>
                                <c:showBubbleSize val="0"/>
                            </c:dLbls>
                            <c:gapWidth val="219"/>
                            <c:overlap val="-27"/>
                            <c:axId val="552556360"/>
                            <c:axId val="552565544"/>
                        </c:barChart>
                        <c:catAx>
                            <c:axId val="552556360"/>
                            <c:scaling>
                                <c:orientation val="minMax"/>
                            </c:scaling>
                            <c:delete val="0"/>
                            <c:axPos val="b"/>
                            <c:numFmt formatCode="General" sourceLinked="1"/>
                            <c:majorTickMark val="none"/>
                            <c:minorTickMark val="none"/>
                            <c:tickLblPos val="nextTo"/>
                            <c:spPr>
                                <a:noFill/>
                                <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr">
                                    <a:solidFill>
                                        <a:schemeClr val="tx1">
                                            <a:lumMod val="15000"/>
                                            <a:lumOff val="85000"/>
                                        </a:schemeClr>
                                    </a:solidFill>
                                    <a:round/>
                                </a:ln>
                                <a:effectLst/>
                            </c:spPr>
                            <c:txPr>
                                <a:bodyPr rot="-60000000" spcFirstLastPara="1" vertOverflow="ellipsis" vert="horz" wrap="square" anchor="ctr" anchorCtr="1"/>
                                <a:lstStyle/>
                                <a:p>
                                    <a:pPr>
                                        <a:defRPr sz="900" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">
                                            <a:solidFill>
                                                <a:schemeClr val="tx1">
                                                    <a:lumMod val="65000"/>
                                                    <a:lumOff val="35000"/>
                                                </a:schemeClr>
                                            </a:solidFill>
                                            <a:latin typeface="+mn-lt"/>
                                            <a:ea typeface="+mn-ea"/>
                                            <a:cs typeface="+mn-cs"/>
                                        </a:defRPr>
                                    </a:pPr>
                                    <a:endParaRPr lang="it-IT"/>
                                </a:p>
                            </c:txPr>
                            <c:crossAx val="552565544"/>
                            <c:crosses val="autoZero"/>
                            <c:auto val="1"/>
                            <c:lblAlgn val="ctr"/>
                            <c:lblOffset val="100"/>
                            <c:noMultiLvlLbl val="0"/>
                        </c:catAx>
                        <c:valAx>
                            <c:axId val="552565544"/>
                            <c:scaling>
                                <c:orientation val="minMax"/>
                            </c:scaling>
                            <c:delete val="0"/>
                            <c:axPos val="l"/>
                            <c:majorGridlines>
                                <c:spPr>
                                    <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr">
                                        <a:solidFill>
                                            <a:schemeClr val="tx1">
                                                <a:lumMod val="15000"/>
                                                <a:lumOff val="85000"/>
                                            </a:schemeClr>
                                        </a:solidFill>
                                        <a:round/>
                                    </a:ln>
                                    <a:effectLst/>
                                </c:spPr>
                            </c:majorGridlines>
                            <c:numFmt formatCode="General" sourceLinked="1"/>
                            <c:majorTickMark val="none"/>
                            <c:minorTickMark val="none"/>
                            <c:tickLblPos val="nextTo"/>
                            <c:spPr>
                                <a:noFill/>
                                <a:ln>
                                    <a:noFill/>
                                </a:ln>
                                <a:effectLst/>
                            </c:spPr>
                            <c:txPr>
                                <a:bodyPr rot="-60000000" spcFirstLastPara="1" vertOverflow="ellipsis" vert="horz" wrap="square" anchor="ctr" anchorCtr="1"/>
                                <a:lstStyle/>
                                <a:p>
                                    <a:pPr>
                                        <a:defRPr sz="900" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">
                                            <a:solidFill>
                                                <a:schemeClr val="tx1">
                                                    <a:lumMod val="65000"/>
                                                    <a:lumOff val="35000"/>
                                                </a:schemeClr>
                                            </a:solidFill>
                                            <a:latin typeface="+mn-lt"/>
                                            <a:ea typeface="+mn-ea"/>
                                            <a:cs typeface="+mn-cs"/>
                                        </a:defRPr>
                                    </a:pPr>
                                    <a:endParaRPr lang="it-IT"/>
                                </a:p>
                            </c:txPr>
                            <c:crossAx val="552556360"/>
                            <c:crosses val="autoZero"/>
                            <c:crossBetween val="between"/>
                        </c:valAx>
                        <c:spPr>
                            <a:noFill/>
                            <a:ln>
                                <a:noFill/>
                            </a:ln>
                            <a:effectLst/>
                        </c:spPr>
                    </c:plotArea>
                    <c:legend>
                        <c:legendPos val="b"/>
                        <c:overlay val="0"/>
                        <c:spPr>
                            <a:noFill/>
                            <a:ln>
                                <a:noFill/>
                            </a:ln>
                            <a:effectLst/>
                        </c:spPr>
                        <c:txPr>
                            <a:bodyPr rot="0" spcFirstLastPara="1" vertOverflow="ellipsis" vert="horz" wrap="square" anchor="ctr" anchorCtr="1"/>
                            <a:lstStyle/>
                            <a:p>
                                <a:pPr>
                                    <a:defRPr sz="900" b="0" i="0" u="none" strike="noStrike" kern="1200" baseline="0">
                                        <a:solidFill>
                                            <a:schemeClr val="tx1">
                                                <a:lumMod val="65000"/>
                                                <a:lumOff val="35000"/>
                                            </a:schemeClr>
                                        </a:solidFill>
                                        <a:latin typeface="+mn-lt"/>
                                        <a:ea typeface="+mn-ea"/>
                                        <a:cs typeface="+mn-cs"/>
                                    </a:defRPr>
                                </a:pPr>
                                <a:endParaRPr lang="it-IT"/>
                            </a:p>
                        </c:txPr>
                    </c:legend>
                    <c:plotVisOnly val="1"/>
                    <c:dispBlanksAs val="gap"/>
                    <c:showDLblsOverMax val="0"/>
                </c:chart>
                <c:spPr>
                    <a:solidFill>
                        <a:schemeClr val="bg1"/>
                    </a:solidFill>
                    <a:ln w="9525" cap="flat" cmpd="sng" algn="ctr">
                        <a:solidFill>
                            <a:schemeClr val="tx1">
                                <a:lumMod val="15000"/>
                                <a:lumOff val="85000"/>
                            </a:schemeClr>
                        </a:solidFill>
                        <a:round/>
                    </a:ln>
                    <a:effectLst/>
                </c:spPr>
                <c:txPr>
                    <a:bodyPr/>
                    <a:lstStyle/>
                    <a:p>
                        <a:pPr>
                            <a:defRPr/>
                        </a:pPr>
                        <a:endParaRPr lang="it-IT"/>
                    </a:p>
                </c:txPr>
            </c:chartSpace>
        </pkg:xmlData>
    </pkg:part>
    <pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
        <pkg:xmlData>
            <w:document xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" >
                <w:body>
                    <w:p w:rsidR="00C75AEB" w:rsidRDefault="000F3EFF">
                        <w:r>
                            <w:rPr>
                                <w:noProof/>
                            </w:rPr>
                            <w:drawing>
                                <wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="4175D679" wp14:editId="60B1BB5E">
                                    <wp:extent cx="5486400" cy="3200400"/>
                                    <wp:effectExtent l="0" t="0" r="0" b="0"/>
                                    <wp:docPr id="1" name="Chart 1"/>
                                    <wp:cNvGraphicFramePr/>
                                    <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                                        <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/chart">
                                            <c:chart xmlns:c="http://schemas.openxmlformats.org/drawingml/2006/chart" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId111"/>
                                        </a:graphicData>
                                    </a:graphic>
                                </wp:inline>
                            </w:drawing>
                        </w:r>
                    </w:p>
                </w:body>
            </w:document>
        </pkg:xmlData>
    </pkg:part>
    <pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml">
        <pkg:xmlData>
            <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
                <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/chart" Target="/word/charts/chart1.xml" Id="rId111" />
            </Relationships>
        </pkg:xmlData>
    </pkg:part>
    <pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml">
        <pkg:xmlData>
            <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
                <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="/word/document.xml" Id="R96cd65a3975c42c6" />
            </Relationships>
        </pkg:xmlData>
    </pkg:part>
</pkg:package>

另一方面,我很难找到如何插入像瀑布图这样的扩展图表。我试图在一个空的MS Word文档中创建一个瀑布图,并分析它的Ooxml代码,我注意到这种图表使用了一个不同的命名空间(cx:chart 而不是 c:chart),并使用一个扩展部分而不是经典的图表部分(内容类型是 application/vnd.ms-office.chartex+xml 而不是 application/vnd.openxmlformats-officedocument.drawingml.chart+xml). 所以,我试着插入以下内容 Ooxml:

<?mso-application progid="Word.Document"?>
<pkg:package xmlns:pkg="http://schemas.microsoft.com/office/2006/xmlPackage">
    <pkg:part pkg:name="/word/document.xml" pkg:contentType="application/vnd.openxmlformats-officedocument.wordprocessingml.document.main+xml">
        <pkg:xmlData>
            <w:document xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:cx1="http://schemas.microsoft.com/office/drawing/2015/9/8/chartex" xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main" xmlns:wp="http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing" xmlns:wp14="http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing" >
                <w:body>
                    <w:p w:rsidR="00C75AEB" w:rsidRDefault="000F3EFF">
                        <w:r>
                            <mc:AlternateContent xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006">
                                <mc:Choice Requires="cx1">
                                    <w:drawing>
                                        <wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="43C8E861" wp14:editId="0D87AFE0">
                                            <wp:extent cx="5486400" cy="3200400"/>
                                            <wp:effectExtent l="0" t="0" r="0" b="0"/>
                                            <wp:docPr id="1" name="Chart 1"/>
                                            <wp:cNvGraphicFramePr/>
                                            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                                                <a:graphicData uri="http://schemas.microsoft.com/office/drawing/2014/chartex">
                                                    <cx:chart xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" r:id="rId111"/>
                                                </a:graphicData>
                                            </a:graphic>
                                        </wp:inline>
                                    </w:drawing>
                                </mc:Choice>
                                <mc:Fallback>
                                    <w:drawing>
                                        <wp:inline distT="0" distB="0" distL="0" distR="0" wp14:anchorId="43C8E861" wp14:editId="0D87AFE0">
                                            <wp:extent cx="5486400" cy="3200400"/>
                                            <wp:effectExtent l="0" t="0" r="0" b="0"/>
                                            <wp:docPr id="1" name="Chart 1"/>
                                            <wp:cNvGraphicFramePr>
                                                <a:graphicFrameLocks xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" noGrp="1" noDrilldown="1" noSelect="1" noChangeAspect="1" noMove="1" noResize="1"/>
                                            </wp:cNvGraphicFramePr>
                                            <a:graphic xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main">
                                                <a:graphicData uri="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                                    <pic:pic xmlns:pic="http://schemas.openxmlformats.org/drawingml/2006/picture">
                                                        <pic:nvPicPr>
                                                            <pic:cNvPr id="1" name="Chart 1"/>
                                                            <pic:cNvPicPr>
                                                                <a:picLocks noGrp="1" noRot="1" noChangeAspect="1" noMove="1" noResize="1" noEditPoints="1" noAdjustHandles="1" noChangeArrowheads="1" noChangeShapeType="1"/>
                                                            </pic:cNvPicPr>
                                                        </pic:nvPicPr>
                                                        <pic:blipFill>
                                                            <a:blip r:embed="rId5"/>
                                                            <a:stretch>
                                                                <a:fillRect/>
                                                            </a:stretch>
                                                        </pic:blipFill>
                                                        <pic:spPr>
                                                            <a:xfrm>
                                                                <a:off x="0" y="0"/>
                                                                <a:ext cx="5486400" cy="3200400"/>
                                                            </a:xfrm>
                                                            <a:prstGeom prst="rect">
                                                                <a:avLst/>
                                                            </a:prstGeom>
                                                        </pic:spPr>
                                                    </pic:pic>
                                                </a:graphicData>
                                            </a:graphic>
                                        </wp:inline>
                                    </w:drawing>
                                </mc:Fallback>
                            </mc:AlternateContent>
                        </w:r>
                    </w:p>
                </w:body>
            </w:document>
        </pkg:xmlData>
    </pkg:part>
    <pkg:part pkg:name="/word/charts/chartEx1.xml" pkg:contentType="application/vnd.ms-office.chartex+xml">
        <pkg:xmlData>
            <cx:chartSpace xmlns:a="http://schemas.openxmlformats.org/drawingml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns:cx="http://schemas.microsoft.com/office/drawing/2014/chartex">
                <cx:chartData>
                    <cx:data id="0">
                        <cx:strDim type="cat">
                            <cx:f>Sheet1!$A$2:$A$9</cx:f>
                            <cx:lvl ptCount="8">
                                <cx:pt idx="0">Category 1</cx:pt>
                                <cx:pt idx="1">Category 2</cx:pt>
                                <cx:pt idx="2">Category 3</cx:pt>
                                <cx:pt idx="3">Category 4</cx:pt>
                                <cx:pt idx="4">Category 5</cx:pt>
                                <cx:pt idx="5">Category 6</cx:pt>
                                <cx:pt idx="6">Category 7</cx:pt>
                                <cx:pt idx="7">Category 8</cx:pt>
                            </cx:lvl>
                        </cx:strDim>
                        <cx:numDim type="val">
                            <cx:f>Sheet1!$B$2:$B$9</cx:f>
                            <cx:lvl ptCount="8" formatCode="General">
                                <cx:pt idx="0">100</cx:pt>
                                <cx:pt idx="1">20</cx:pt>
                                <cx:pt idx="2">50</cx:pt>
                                <cx:pt idx="3">-40</cx:pt>
                                <cx:pt idx="4">130</cx:pt>
                                <cx:pt idx="5">-60</cx:pt>
                                <cx:pt idx="6">70</cx:pt>
                                <cx:pt idx="7">140</cx:pt>
                            </cx:lvl>
                        </cx:numDim>
                    </cx:data>
                </cx:chartData>
                <cx:chart>
                    <cx:title pos="t" align="ctr" overlay="0" />
                    <cx:plotArea>
                        <cx:plotAreaRegion>
                            <cx:series layoutId="waterfall" uniqueId="{8256AF32-3F39-4C50-900C-275ED2F52034}">
                                <cx:tx>
                                    <cx:txData>
                                        <cx:f>Sheet1!$B$1</cx:f>
                                        <cx:v>Series1</cx:v>
                                    </cx:txData>
                                </cx:tx>
                                <cx:dataLabels pos="outEnd">
                                    <cx:visibility seriesName="0" categoryName="0" value="1" />
                                </cx:dataLabels>
                                <cx:dataId val="0" />
                                <cx:layoutPr>
                                    <cx:subtotals>
                                        <cx:idx val="0" />
                                        <cx:idx val="4" />
                                        <cx:idx val="7" />
                                    </cx:subtotals>
                                </cx:layoutPr>
                            </cx:series>
                        </cx:plotAreaRegion>
                        <cx:axis id="0">
                            <cx:catScaling gapWidth="0.5" />
                            <cx:tickLabels />
                        </cx:axis>
                        <cx:axis id="1">
                            <cx:valScaling />
                            <cx:majorGridlines />
                            <cx:tickLabels />
                        </cx:axis>
                    </cx:plotArea>
                    <cx:legend pos="t" align="ctr" overlay="0" />
                </cx:chart>
            </cx:chartSpace>
        </pkg:xmlData>
    </pkg:part>
    <pkg:part pkg:name="/word/_rels/document.xml.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml">
        <pkg:xmlData>
            <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
                <Relationship Type="http://schemas.microsoft.com/office/2014/relationships/chartEx" Target="/word/charts/chartEx1.xml" Id="rId111" />
            </Relationships>
        </pkg:xmlData>
    </pkg:part>
    <pkg:part pkg:name="/_rels/.rels" pkg:contentType="application/vnd.openxmlformats-package.relationships+xml">
        <pkg:xmlData>
            <Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships">
                <Relationship Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/officeDocument" Target="/word/document.xml" Id="R96cd65a3975c42c6" />
            </Relationships>
        </pkg:xmlData>
    </pkg:part>
</pkg:package>

但是 insertOoxml 方法抛出的是一个 GeneralException.

我缺少什么?

如何插入一个瀑布图,插入它的Ooxml?

charts ms-word office-js openxml word-addins
1个回答
1
投票

你可以试试这个 瀑布ooxml 从一个MSDN论坛上得到了这个,你可以从这个OOXML中得到参考。

© www.soinside.com 2019 - 2024. All rights reserved.