The type provider type uses the following code to specify the template:
type T = Samples.ShareInfo.TPTest.TPTestType<"AA.docx">
The AA.docx is treat as the template for this type provider. And the constructor get a file name which will be generated from the template.
let t = T("MRXYZ.docx")
The above statement is to use the AA.docx template and generate the MRXYZ.docx file. The rest of the code is to set fields.
t.Person <- br="br" r.="r." xyz="xyz">t.ContactInformation <- br="br" com="com">t.MyCompany <- br="br" company="company">t.MyName <- br="br" lee="lee" ohn="ohn">t.NewProduct <- blockquote="blockquote" new="new" product="product">According to a user's feedback, I added a new feature for this type provider. This feature will make sure all the fields are assigned a value. If there is a field missing, then the .Close function will generate an exception.
Please make sure you do t.Close() to flush the content to the hard disk. The generated file MRXYZ.docx is located at the same folder as AA.docx. And the content of the file is
If you click "ABC Company" or other fields, you can find the "Update Field" is disabled. You can use this approach to get the data from any data storage and export to Word Document.
For details, please download the source code from F# 3.0 Sample Pack. See the screenshot below: