Events / Listeners in OpenXML SDK RRS feed

  • Question

  • Hi

    I have written a desktop application that produces a word document using OpenXML SDK 2.0.

    Details about the document:
    a. The document has a list of streets and reference numbers displayed in two-column page layout. (Very similar to the yellow pages 'Name & Telephone Number' layout )

    b. The data for the document (streets and reference numbers) comes from an external source (XML file)

    c. I would like to display the header "Street Number                        Ref No" at the start of the column

    Here is what I have done so far:

    WordprocessingDocument wordDocument =  
    WordprocessingDocumentType.Document); // ........... snip ..... List<OpenXmlElement> paragraphs = new List<OpenXmlElement>(); // read the streets from the xml file int count = 0; for (Street street in streets) { count++; if (count == 63) { addColumnBreakParagraph(paragraphs); addColumnHeaderParagraph(paragraphs); count = 0; } addStreetParagraph(street,paragraphs); } OpenXmlElement[] paragraphArray = paragraphs.ToArray(); Body body = new Body(paragraphArray); Document document = new Document(body); (wordDocument.AddMainDocument()); // ----------------------------------------------------- // Methods not shown in the snippet: // ----------------------------------------------------- // addColumnBreakParagraph : adds a blank paragraph with a column break // addColumnHeaderParagraph: adds a paragraph with the text "Street Name Ref Number" // addStreetParagraph : adds a paragraph with the street name and Ref Number
    As you can see from the code, I am assuming that there will be 63 street entries per column and I force a column break once the count reaches 63.

    I am not happy with this approach as the Street can have multiple lines / different font size.

    I am wondering whether OpenXML has some concept of listener or event so that the code (before inserting a paragraph) can check whether the paragraph to be inserted would fit in the current column or not. Should the new paragraph not fit, the code should insert a column break and column header.

    Or is there an easier / alternate / better way to do this?

    Any ideas / suggestions regarding this are welcome.

    Wednesday, November 4, 2009 5:53 AM

All replies

  • As I know, Open XML SDK doesn't have events/listeners concept in CTPs.

    Tuesday, November 17, 2009 5:46 AM
  • Unfortunately, the scenario you listed above requires some kind of layout or pagination technology to be built in within the Open XML SDK. As of now, the Open XML SDK does not have this functionality and does not have events/listeners.

    Are there other events/listeners that do not require layout that you would like to use?

    Zeyad Rajabi (MS)
    Monday, November 23, 2009 10:52 PM