开发者

XMLSS Style Inheritance

I am working on creating Excel workbooks in XML, by way of XMLSS, and I've found myself stuck in one particular place.

According to the documentation at http://msdn.microsoft.com/en-us/library/aa140066(office.10).aspx#odc_xmlss_ss:style, the <ss:Style /> tag has an available property, ss:Parent, which allows the given style to inherit the attributes of a previously defined style. However, I am having a terrible time getting this to work.

I receive no errors whatsoever when I open the workbook, and the child style's attributes are applied properly, but none of the attributes from the parent style carry over.

As XMLSS is not very well documented outside of the MSDN docs, I come to the StackOverflow crowd for help. Are there any caveats to using the ss:Parent poperty within the <ss:开发者_JS百科Style /> elements?


Hi user352078 (catchy name that is)

Actually inheritance of styles in SpreadsheetML (via "ss:Parent=") does work (at least it does for me) but you might have encountered a -- nowhere documented, as far as I could see -- problem: If you redefine a style element (in the below example ) you wont inherit styles that have already defined. So sty_ProjektzeileStatus has to define every aspect of the Borders-Style, although I have the same style for Bottom (i.e. LineStyle:"Dash" etc.).

So if Borders gets redefined in an inheriting style, all existing styledefinitions for Borders are thrown out and have to be defined (what is actually not too bad because that way you don't have to explicitly delete existing styles from the parent style in inheriting styles).

<Style ss:ID="sty_ProjektzeileTexte" ss:Name="Texte">
   <Font ss:Bold="1" />
   <NumberFormat ss:Format="Standard" />
   <Borders>
      <Border ss:Position="Bottom" ss:LineStyle="Dash" ss:Weight="1" />
   </Borders>
</Style>

<Style ss:ID="sty_ProjektzeileStatus" ss:Parent="sty_ProjektzeileTexte">
   <!-- Overwrites original definition -->
   <NumberFormat ss:Format="0" />
   <!-- Although only Right line is added to the original definition from the parent style, 
        all 'sides' of the border element need to be defined, 
        even style for Bottom that is unchanged -->
   <Borders>
      <Border ss:Position="Bottom" ss:LineStyle="Dash" ss:Weight="1" />
      <Border ss:Position="Right" ss:LineStyle="Continuous" ss:Weight="2" />
   </Borders>
   <!-- Only fontstyle Bold is actually inherited -->
</Style>

I hope that answers your question. I just remeber encountering once a problem with setting names (ss:Name=) in both parent and child styles that had some unexpected consequences, but I can't remember if that as well resulted in spoilt inheritance).

HTH

Andreas

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜