Eric White
Forum Replies Created
-
AuthorPosts
-
Probably converting to an image would be the most straight-forward. Word does has a stacked horizontal bar chart, so you could use the approach in the following screen-cast to update data for your chart.
Thinking out of the box – another approach works only with Office 2016 (and maybe 2013) – you could write a JavaScript Add-In and ‘include’ your bar chart graph as written in javascript/jquery.
So the question is, can we put together another ‘WindowsBase’ assembly that contains everything except System.IO.Packaging.
This certainly sounds like a bug. I’ll attend to this in the next week or so. Should not be hard to fix.
I’ll tell you what I would do – I would, just to educate myself, dive into the reference source, and see how complicated those types are. You may be able to mitigate with a minimum of effort.
http://referencesource.microsoft.com/
I have to confess – I am not a linker guru, but there probably is a way to extract your required types from the WindowsBase assembly. Scanning the reference source might provide a clue.
Will you please take a look and let me know what you find?
One more question – can you take a junk copy of your source, and hack out the references, and just those references that cause the dependency on WindowsBase, and see if it is a very select few APIs or if VSTO has a pretty hard dependency on the types in WindowsBase other than System.IO.Packaging?
Regarding the issue that the name is “package.bin”, the name of the file in the zip is irrelevant. Open XML does not specify, nor does it care. The only thing that matters are the relationship type and content type. When you do this call:
`chartPart.AddNewPart
(“application/vnd.openxmlformats-officedocument.spreadsheetml.sheet”, relationID) This sets the relationship and content types correctly.
March 11, 2016 at 4:15 am in reply to: Import Table containing complex objects to another Word Document. #2507Hi Prince,
What you need to use is DocumentBuilder, which will appropriately bring in referenced charts, smart art, images, everything.
Please see the following content on DocumentBuilder:
DocumentBuilder Developer Center
In particular, pay attention to #8, Fine-grained control when importing content using DocumentBuilder.
Cheers, Eric
Hi Marcus,
What kind of application are you building, i.e. ASP.NET, UWP, etc? What .NET framework are you using?
What is the code that is referring to System.Windows-Freezable?
It is not common for code to refer to the other bits in WindowsBase, so I am curious what is the circumstance where this occurs. Then we have to put together an approach to resolve the issues.
Cheers, Eric
Hi Ryan,
It has been several years since I worked with shapes, and even then didn’t do a great deal.
But if I recall correctly, there is a fairly sophisticated ‘roll-up’ of positional properties in DrawingML. I remember a case where I was tasked with validating positions as calculated, and I dug into the spec, did the calculations, including rolling up of layout slides and master slide, and at the end of the process, discussed with the developer the exact algorithm to determine positions and etc. I don’t recall the details.
I recommend that you review section 5.7 in the Open XML Part 3 – Primer. It will explain what you need to know.
You can get it at this link:
http://www.ecma-international.org/publications/standards/Ecma-376.htm
Think link to Ecma 376 First Edition Part 3 is down near the bottom.
Here is the direct link to the PDF.
Cheers, Eric
In general, you should never create a workbook / spreadsheet package from scratch. It is far better to start with an existing, blank workbook, or a workbook that has a prototype chart. You can keep the ‘template’ workbook in a .NET resource, or you can include it directly in your code encoded in a string as base64Ascii.
While the following content is about WordprocessingML and PresentationML, the principles in it apply to updating charts in SpreadsheetML. Much of the code could be re-purposed to update charts in SpreadsheetML.
Updating Data for an Embedded Chart in an Open XML WordprocessingML Document
March 8, 2016 at 6:01 pm in reply to: Merge 3 document, discard footer or header separatly into one document #2491Hi,
There is no functionality in DocumentBuilder to take the header from one section and the footer from another section. It is not a feature of DocumentBuilder. It is possible to manually write code to do this – it is probably only 30 or so lines of code. But you need to understand the below information.
I am not clear on the error that you are seeing.
Actually, sections / headers / footers are more complicated than would seem on first glance.
First of all, there can be 1, 2, or 3 headers per section. Ditto for footers. Depending on default, even, or odd, then the others are set per some specific rules, documented in the standard. Further, sections can inherit from previous sections.
In DocumentBuilder, there is a method, ProcessSectionsForLinkToPreviousHeadersAndFooters, which ‘normalizes’ headers and footers in sections. For instance, it makes sure that there are 3 headers and 3 footers per section, therefore the ‘interesting’ rules about how to determine the header or footer for a section are eliminated. Further, if a section inherits from a previous section, then the previous section’s headers and footers are placed in the section. After executing the method, every section has 3 headers and 3 footers, and no section inherits from a previous section.
Then processing gets easier and more predictable within DocumentBuilder. Developers should be aware of these dynamics when using DocumentBuilder.
Given my current schedule, I’m afraid I can’t debug the modifications to DocumentBuilder. It would take some time to get back into the internals of DocumentBuilder, and given what I need to get done, isn’t possible at the moment.
You have an interesting use-case, and would be interested to hear more. Why do you need to get the header from one document, but the footer from another? Would love to hear the specific scenario. I love to learn new things about how people use Word.
Cheers, Eric
- This reply was modified 8 years, 8 months ago by Eric White.
I’ll see what I can do. I have some personal commitments over the next 3 days.
My idea is to create a new Open-Xml-PowerTools example, which contains two documents with conflicting numbering styles, where we want to take the numbering definitions from the second document in the sources.
Have you looked at all of the existing DocumentBuilder examples, and understand setting up sources for DocumentBuilder? It would be worthwhile to go into the four examples, play with them, changing the sources, changing the number of paragraphs in each source, and so on.
Trust me, I fully understand how complicated numbering is. I wrote an MSDN article, Working with Numbered Lists in Open XML WordprocessingML. I then wrote the ListItemRetriever module which is a reference implementation of retrieving list items, and then eventually re-wrote it again. I suppose I have spent three full months working with numbering, so believe me, I know.
Copying the numbering part from one document to another is not a good approach. It might work in this specific scenario, but has the potential to break the document far too easily.
The problem you are facing is that the template document does not contain the definition for the numbering in Doc A – instead, it has some conflicting numbering defined for that particular numbering ID. (Numbering ids are the key identifier – abstract numbering is a level of indirection that enables reuse of the core numbering definition in multiple numIds.)
Here is an easy way to solve your problem.
When you set up your list of sources for DocumentBuilder, first include the numbered content at the beginning of the document. This should be the first source in your list of sources. Make a note of the number of paragraphs that you have inserted. This will pull in the numbering definitions from Doc A.
Then set up the remainder of your sources exactly as you are currently doing, and fire off DocumentBuilder. This will create a document with the correct numbering, in row 2 of your table.
Now, after DocumentBuilder is finished, open up the resulting document and delete those extra paragraphs that you have inserted at the beginning of the document. This is easy code to write, because you have saved away the number of paragraphs that you have inserted.
Then you will have a document that looks like what you want.
The problem here is that I believe that DocumentBuilder is pulling the definition of the numbered list from an earlier document in the list of sources. There are multiple ways that numbering can be set up in a document, and one of the ways is that numbering is applied to styles, i.e. Heading1, Heading2, Heading3 have numbering applied to them. Is this the case with your documents?
Depending on your use case, there is an easy way to resolve this, which is to use FormattingAssembler to create a new document where numbering is ‘flattened’. The resulting document does not use numbering, and instead, there is a new run that contains the correct list item. You then use the ‘flattened’ document as your source(s) for DocumentBuilder.
So to debug this further, I need to know if in fact you have multiple documents in your list of sources, and what kind of numbered lists you are using.
I haven’t yet determined how to enable attaching files to forum posts using bbPress. Can you upload your source documents (simplified if possible) to OneDrive or DropBox, and then post the link?
Cheers, Eric
-
AuthorPosts