问题
Office 2007 brings a new goodie called as 'content controls'. I need to evaluate this to see if this serves as a solution for a problem under research.
Due to paucity of time and my general disdain for Office-interop-pains,
- can someone summarize the benefits?
- Is it possible to define custom content controls?
- where do all the word programmers (if there are any) hang out :) ?
RTFMsdn links also welcome.
So far I see (from some screencasts) that its now possible to define - template word docs whose content can be stubbed in from a data-behind-XML. You could create this XML as you wish.. e.g. translate contents of your DB into an XML form. The word doc can now 'data-bind' to this XML.
回答1:
Well after 2 days of research, here's what I found.
Content Controls are the next step in evolution from the old bookmarks..
- Protection - you can protect content-controls in your document such that the user cannot edit them. e.g. the terms of the contract may not be editable like the rest of the doc
- Data binding - you can create 'forms' in a word doc with content controls that bind to a custom xml via a visual designer. 2-way: Changing the xml updates the controls in the word doc and vice versa. Throw in an xml schema for your xml and you can have user-input validation as well. Content Controls can bind to individual xml nodes via XPath.
- Events - content controls expose events that you can handle to do custom processing.
- Document auto-generation - With some knowledge of the IO.Packaging namespace, the Open XML specs + Visual Studio, You can create a skeleton document and then churn out actual documents (e.g. invoices) by supplying a different data store/object (custom xml). You can also do something like .net 'DataTemplates' - e.g. This is how each order line item should look like.. repeat this for n line items in the xml
Best at-a-glance post: http://blogs.msdn.com/kathleen/archive/2007/06/20/my-favorite-feature-word-content-controls.aspx
Mike Ormond’s screencasts - http://blogs.msdn.com/mikeormond/archive/2007/05/24/office-open-xml-file-format-nuggets.aspx
来源:https://stackoverflow.com/questions/221300/what-are-the-benefits-of-ms-word-content-controls