none
OpenXML SDK problem accessing Styles/Image/Header/Footer parts RRS feed

  • Question

  • I am trying to create rdl file, using OpenXML SDK to extract data from word (docx) file. I have more or less, figured out how to get paragraphs, runs, images, tables and such…

    Problems are appearing when I try to set paragraph/run properties. If settings are set in pPr or rPr tag I can read it fine, but if settings are referenced via pStyle or rStyle I have problem.

    First I couldn’t find document part referring to styles.xml, header.xml, footer.xml… Basically none of the files referenced in /_rels/document.xml.rels. Then I figured out that couldn’t see that files because they are kept within MainDocumentPart and document.xml is kept in MainDocumentPart.Document[.Body].

    And now that I have found that files, I don’t know how to use them. I can access them, but only as packages. I don’t know how to find style referenced in pStyle/rStyle tag.

    My workaround for this problem was using XPath. It works sometimes, but not always. Main problem is, for example:

    If I have tag: <w:pStyle w:val="My Style" />

    It then reference to paragraph style “My Style” and that style is referencing character style “My style” and if that style is extending some style, it’s referencing that style to. If naming is constant, I don’t have problem, because I keep using XPath as long as references are available.

    BUT…

    Main problem is that <w:pStyle w:val="My Style" /> can be referencing to style named MyStyle or mystle or Style My… And I have no way of knowing that from name “My Style”. Word have some way of tracking that… So that’s the main reason I want to use OpenXML SDK for style management.

     

    Any advice?

    Wednesday, January 28, 2009 12:40 PM