WorkbookPart.Workbook.Save()添加x: [英] WorkbookPart.Workbook.Save() adds x:
问题描述
我的应用程序有点问题,应该将定义的名称添加到电子表格中。这是执行工作的代码:
I have a slight problem with my application, which is supposed to add definedNames to a spreadsheet. Here's the Code that does the work:
DefinedNames definedNames = myDocument.WorkbookPart.Workbook.DefinedNames;
if (!classified)
{
if (definedNames == null)
{
//instead of this comment a bunch of DefinedNames are created an appended to definedNames here
myDocument.WorkbookPart.Workbook.Append(definedNames);
}
else
{
//here i append some definedNames as well
myDocument.WorkbookPart.Workbook.DefinedNames.Append(definedName4);
}
}
else
{
foreach (DefinedName dv in definedNames)
{
//some definedName appending
}
}
myDocument.WorkbookPart.Workbook.Save();
运行之前此代码woorkbook.xml文件如下所示:
Before running this code the woorkbook.xml file looks like this
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<workbook xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<fileVersion rupBuild="9302" lowestEdited="4" lastEdited="5" appName="xl"/>
<workbookPr defaultThemeVersion="124226" filterPrivacy="1"/>
-<bookViews>
<workbookView activeTab="1" firstSheet="1" windowHeight="8010" windowWidth="14805" yWindow="105" xWindow="240"/>
</bookViews>
-<sheets>
<sheet r:id="rId2" sheetId="1" name="Tabelle1"/>
<sheet r:id="rId3" sheetId="2" name="Tabelle2"/>
<sheet r:id="rId4" sheetId="3" name="Tabelle3"/>
</sheets>
-<definedNames>
<definedName>... </definedName>
</definedNames><calcPr calcId="122211"/></workbook>
然后它看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<x:workbook xmlns:x="http://schemas.openxmlformats.org/spreadsheetml/2006/main" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships">
<x:fileVersion rupBuild="9302" lowestEdited="4" lastEdited="5" appName="xl"/><x:workbookPr defaultThemeVersion="124226" filterPrivacy="1"/>
-<x:bookViews>
<x:workbookView activeTab="1" firstSheet="1" windowHeight="8010" windowWidth="14805" yWindow="105" xWindow="240"/>
</x:bookViews>
-<x:sheets>
<x:sheet r:id="rId2" sheetId="1" name="Tabelle1"/>
<x:sheet r:id="rId3" sheetId="2" name="Tabelle2"/>
<x:sheet r:id="rId4" sheetId="3" name="Tabelle3"/>
</x:sheets>
-<x:definedNames>
<x:definedName>....</x:definedName>
</x:definedNames><x:calcPr calcId="122211"/></x:workbook>
另一个程序应该在之后读取那些定义的名称。但那些darn x阻止它这样做。即使没有对工作表执行任何操作,也只会调用save()方法,这些x就会出现。有什么方法可以阻止save()
添加那些x?
Another programm is supposed to read those defined names afterwards. But those darn x prevent it from doing so. And those x appear even if no action is performed on the worksheet and only the save() method is called. Is there any way i can prevent save() from adding those x?
任何帮助都是经过评估的:)
Any Help is apprecheated :)
干杯
推荐答案
Hi MrTompkins,
我看不出你们展示的两个xml内容之间有什么不同。在您的代码段中,我看不到定义变量" definedName4 "的位置。你需要更清楚地澄清它。
I can't see any different between two xml content which you shown tome. And in you snippet I can't see the place which defined the variable "definedName4". You need clarify it more clearly.
最好的问候,
T.X。
这篇关于WorkbookPart.Workbook.Save()添加x:的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!