Eric White

Forum Replies Created

Viewing 15 posts - 106 through 120 (of 253 total)
  • Author
    Posts
  • in reply to: OpenXML word template multiple pages #3642

    Eric White
    Keymaster

    Hi,

    It sounds as though your project is an ideal one for DocumentAssembler, which is a module in Open-Xml-PowerTools that enables document assembly.

    DocumentAssembler Developer Center

    Take a look at the screen-casts at the above link, and see if this is a good direction for you to go.

    -Eric

    in reply to: Using Content Select to insert formatted text blocks #3641

    Eric White
    Keymaster

    Hi Mark,

    This is a very interesting scenario. I didn’t specifically think of this scenario when I designed DocumentAssembler.

    One idea that I’ve had cooking for some time is to enable importing XHtml content. In this approach, you would convert your text to equivalent XHtml (or an approximation thereof), and DocumentAssembler would use the HtmlToWmlConverter module to convert to DOCX. Then, separately, I would enable the use of DocumentBuilder to import that new DOCX into the generated document.

    This isn’t a huge amount of work – a few days at most. However, this is not currently in my schedule. (I am doing some super-cool Open XML work currently, and will be blogging about it soon.)

    One approach you might take – when you see this content, insert some special tags in the document, and then post-process the document, making it as you like.

    I’ve put this on my list of projects.

    -Eric

    in reply to: MainDocumentPart.Annotation returns null #3638

    Eric White
    Keymaster

    Hello,

    Storing XDocument objects as an annotation on the part is a common technique – it is the approach that Open-Xml-PowerTools uses. Where did you get this code? Are you using Open-Xml-PowerTools?

    Cheers

    in reply to: Issue while Exporting excel template #3632

    Eric White
    Keymaster

    Hi,

    Sorry, I’m not clear on what you are using for Excel templates.

    There appears to be some issue with your markup such that you are getting two blank entries in the drop down. I would look to see if they were actually the same, or is one of those some type of invisible character, so you have some cells that are truly blank, and other cells that contain an invisible character, and this would result in getting the strange drop down list.

    Cheers, Eric

    in reply to: OpenXml Ranges Similar to Word Interop #3631

    Eric White
    Keymaster

    Hi Manu,

    What exactly do you mean by character offsets? Are you speaking of the exact, precise character position in the document?

    in reply to: How to identify '\r' carriage return in openxml #3630

    Eric White
    Keymaster

    Hi Manu,

    Entering shift-Enter in Word, i.e. inserting a soft break inserts the w:br element, which is a child of the w:r element.

    There are some great tools that will help you with answering these types of questions. See the ‘Intro to Open XML’ screen-cast series, and look at the tools videos.

    Cheers, Eric

    in reply to: Merging style inheritance elements #3629

    Eric White
    Keymaster

    I remember being told that it is defined in the Implementation Notes, but I can’t find it.

    Anyway, if I were to make a list of the exact, precise rules for style inheritance (and they are sometimes weird, take toggle properties, for instance), I would read the code of FormattingAssembler.cs. That module implements style inheritance properly.

    Sorry I don’t have a better answer for you. This is also what I would need to do – I of course can’t remember all the details. But the code is there, and it is pretty accurate.

    in reply to: locating ang extracting images inside word table #3595

    Eric White
    Keymaster

    Hi,

    Personally, I would use an XML parser to find all of the descendant w:drawing elements. I would not use the strongly-typed OM of the Open-Xml-Sdk for this. I would use LINQ to XML for this.

    Your code will work, but looking through text of XML for specific patterns probably isn’t the best way to proceed.

    -Eric

    in reply to: Create and update custom xml part #3594

    Eric White
    Keymaster

    Hi Vimal,

    This is certainly doable. The Open-Xml-Sdk-Js is somewhat similar to the classes in System.IO.Packaging, in that you can create any variety of part, with any content type, and create a relationship to that part from the main document, or from any other part.

    You have to remember that when creating a custom XML part, you must actually create two parts – there is the part that contains your XML, and that part has a relationship to a properties part. Take a look at a document that contains a custom XML part using the Open XML Package Editor in Visual Studio, in order to see the content type for the custom XML part, and the content type for the properties part, and the various relationship types. Then your job in the Open-Xml-Sdk-JavaScript is to create those same parts, with the same content types, and with relationships with the same relationship types.

    -Eric

    in reply to: OpenXml SDK 1.0 download? #3593

    Eric White
    Keymaster

    Hi Tracy,

    You are indeed right, the link to download the Open XML SDK 1.0 no longer works.

    I just looked, and it appears that I don’t have the 1.0 DLLs at my fingertips. I probably have them in an old backup, but right now I am moving, and all my stuff is packed up. If you will check with me in a couple of weeks, I will be moved into my new office, and can look on my old backups.

    Cheers, Eric

    in reply to: Calculating Text Metrics for TextBox in Word Document #3591

    Eric White
    Keymaster

    This is a non-trivial (but doable) task.

    After many experiments, I found that the text metrics methods in System.Windows.Forms.TextRenderer gave me the best results. This is the text metric functionality that WmlToHtmlConverter uses. You can look at the code in WmlToHtmlConverter as one example of the use of TextRenderer.

    Dealing with rotation means that you will need to remember your basic trigonometry from high school. 🙂

    in reply to: Template system & book #3589

    Eric White
    Keymaster

    Hi Hervé,

    I have not yet written a book, although I have thought a lot about it. What I have done instead is record many screen-casts/videos. The screen-cast series links are in the side bar on this blog, to the right. In particular, watch the screen-cast series on Introduction to Open XML, also watch introduction to WordprocessingML.

    As far as templating systems goes, I am now recommending the approach that I take in the DocumentAssembler module. Please watch these two screen-casts:

    http://www.ericwhite.com/blog/blog/documentassembler-developer-center/

    DocumentBuilder may also be relevant to you. In particular, watch screen-cast #6 in this series:

    http://www.ericwhite.com/blog/blog/documentbuilder-developer-center/

    Best, Eric

    in reply to: Table with no return data #3569

    Eric White
    Keymaster

    Hi Ash,

    The approach I recommend:

    • Put an element (or attribute) in your XML file that indicates whether there is data.
    • In your template, put a conditional block based on the element that indicates whether there is data.
    • Then within the conditional block, import the data into the table.

    This will then hide the message that there is no data.

    Cheers, Eric


    Eric White
    Keymaster

    It is not quite clear to me what you are trying to do, but I can give some small explanation.

    Every embedded object is in fact inside a paragraph. You can tell what paragraph it is in by finding the w:p element that is the ancestor of the object.

    You can find out the type of object by two pieces of information. First of all, you need to look at the markup in the main document part. The markup for an image will be different from the markup for an embedded spreadsheet. Second, you can know more about the embedded object by looking at the relationship type and the content type for the related part. For example, an embedded spreadsheet will have the following markup:





























    We can see the relationship ID to the part that contains the embedded spreadsheet. The relationship ID is rId5.

    If we use the Open XML Package Editor PowerTool for Visual Studio, we can see that the relationship type is:

    http://schemas.openxmlformats.org/officeDocument/2006/relationships/package

    When we look at the related part, we can see the content type is:

    application/vnd.openxmlformats-officedocument.spreadsheetml.sheet

    If you are unfamiliar with relationship and content types, I recommend watching the screen-casts on Open Packaging Conventions. They are screen-casts #11 and #12 in the following series:

    Introduction to Open XML

    I also recommend watching the other screen-casts in that series.

    You would also benefit, I think, from watching the screen-casts on WordprocessingML.


    Eric White
    Keymaster

    I believe that you can do this. After parsing a formula, you must go into the abstract syntax tree, change values (apply your row offset), and then serialize back to a string, which you then set into the formula for the cell.

    That parser was written by Bob McClellan (another developer of Open-Xml-PowerTools), quite some time ago, and I have not made use of it in the fashion you are contemplating. However, I believe it is doable.

    Please let me know how you get on.

Viewing 15 posts - 106 through 120 (of 253 total)