Eric White
Forum Replies Created
-
AuthorPosts
-
Hi Thierry,
Unfortunately, I have no experience in this area.
I presume there is some issue associated with extents or metrics, but it would take some research to figure this out.
After running your workaround/hack sizing the embedded Excel objects via the Word object model, you should get a pretty good idea of what your markup should be by looking at the markup after Word does its thing, do you not?
Best, Eric
October 7, 2016 at 4:34 pm in reply to: The type \'Package\' is defined in an assembly that is not referenced #3873Hi,
When you are using this code in SharePoint, you will need to use WindowsBase. This is the correct approach. Lots of other SharePoint code uses WindowsBase.
I am super-happy that you like Open-Xml-PowerTools. 🙂
Cheers, Eric
Hi,
I am unclear on your question.
When you place a block-level content control in a cell, the w:sdt (and w:sdtContent) surround the w:tc element, as your image shows.
Are you saying that when you get the root element, you see within the root element a table with only one row? This seems pretty surprising to me, and I suspect that I am misunderstanding your question.
You may be interested in using the Open XML Package Editor PowerTool.
See screen-cast #4 in the following series:
Best, Eric
Hi,
Yes, element.InnerText will work, so long as you don’t have tracked revisions, in which case it will not.
Also, frankly, I do not use the strongly typed classes in the Open XML SDK. Instead, as you can see in Open-Xml-PowerTools, I always use LINQ to XML, which is the best XML programming API ever invented, IMO.
In general, with these types of issues, you need to understand the markup in depth, and you need to understand the tools. Please watch screen-cast #13 in the following series:
And of course, you may want to watch others in that series as well.
Best, Eric
Hi Manu,
Please read the following MSDN article:
https://msdn.microsoft.com/en-us/library/office/ff191178.aspx
I think this will help you…
Best, Eric
Hi,
I’m really happy you like the library and videos! I love working with Open XML – it is fun!
I just want to be clear – in addition to selecting text in a document based on matching of a regex, you also want to optionally match based on styling, i.e. bold, italic?
OpenXmlRegex was not designed to do this. However, one of the options to certain OpenXmlRegex overloads is a lambda expression that gets called for each match. One of the arguments to this lambda is the paragraph element, so it could be possible for you to examine this paragraph element and decide whether you want to do the replacement or not. If you return false from the lambda, then the replacement will not happen.
You run into the decision of what to do if a specific paragraph contains text that will match the regular expression more than once – how do you decide whether to replace or not based on styling.
In my opinion, a more robust system simply relies on matching the text. I have taken to the practice of delineating such text using < # and #>. These symbols make sense from a user perspective – they are easy to remember, and they make sense from a programming perspective – those characters in that order are not valid in JavaScript, C#, or XML. So I have standardized on those two characters (which are the same as used for T4 text templates). This is what I would recommend, if it fits your user scenarios.
Let me know how your project goes. 🙂
Best, Eric
Hi,
Can you please post online (dropbox…) the two source documents, and a small C# sample that does the merge? I am very curious as to why this is happening, and want to fix it asap.
Thanks, Eric
September 16, 2016 at 1:09 pm in reply to: MSDN Sample to Create Presentation makes empty presentation #3800Hi Terry,
Have you seen this screen-cast:
Generate Open XML Presentations using a Presentation Template
Cheers, Eric
Just checking – the macro name should be Auto_Open, not AutoOpen.
It may be that Microsoft has completely removed this feature due to security concerns.
September 16, 2016 at 1:04 pm in reply to: Adding/Getting Comments based on character position #3798Yes, you are right, there is not an easy way to get the document position.
In a recent project (WmlComparer), a module that compares two DOCX files and produces a new document that contains the precise differences between them (with certain restrictions), I transform the DOCX into a new form that is an array of the precise content of the document. Each character and image in the document occupy a single element of the array. This array is put together in such a way that it is possible to reconstruct a valid Open XML document from it. This approach resolves the problems associated with the nested nature of Open XML. You may be interested in watching this screen-cast:
It’s a bit long of a screen-cast, but it can illuminate the proper approach to dealing with this issue.
I have in mind a generalization of that approach so that developers can do the type of operations that you want to do, i.e. count specific characters, insert comments at any specific point easily, and so on. Writing WmlComparer really helped me to formalize my thoughts about this issue.
Cheers, Eric
Hi,
Did you get this resolved?
Nothing stands out for me – looks correct.
What I would do in this situation – find the code in DocumentAssembler.cs that evaluates the XPath expression – at that point, you can see the XML that it is querying, you can see the XPath expression, and the results of the query.
Hi Timur,
Yes, I would not go down this path, at this point in time, if I were you. The Open XML SDK has not been validated on Linux.
Cheers, Eric
Hi,
I have no experience about the closedXML library, although I have heard good things about it. Maybe someone else has an answer…
Cheers, Eric
September 15, 2016 at 11:59 am in reply to: Adding/Getting Comments based on character position #3790Hi Gene,
I’m not fully clear on your question.
Comments have markup in the main document part to indicate the start and end of the location of the comment (w:commentRangeStart, w:commentRangeEnd). These elements are situated at the specific location in the document. Then the actual text of the comment is in the comments part, which you must find by following the location.
You will be interested in the following screen-cast:
Key point of that screen-cast: create a word document (without comment), copy the document, in the copy, insert a comment, then use the Open XML SDK productivity tool to compare the two. This will teach you about comment markup.
Cheers, Eric
Hi,
There was a period of time where I was the maintainer of the Open-Xml-Sdk, and we never completed the engineering to enable reliable use on Linux. I know that some devs have gotten it to work, and in some cases have written significant programs, however, I don’t know the details.
At the time, I determined that the highest priority project was (a) complete the re-write of System.IO.Packaging because the old version was unreliable, and (b) create a large set of XUnit tests, with the idea that if those tests ran in Linux, we could be certain that the SDK on Linux was operating properly. However, before I could get on to the port to Linux, the folks at Microsoft decided to go a different direction WRT the Open-Xml-Sdk. I am no longer the maintainer of it.
I have had thoughts about the best way forward, but that project has not risen to the top of the heap.
Cheers, Eric
-
AuthorPosts