...
Info | ||
---|---|---|
| ||
In the sample project, we are parsing CSV files with query results, rather than querying a live database. The CSV files are available under the datadata _directory. There is a copy of the CSV parser, |
...
The final output should resemble this:
Final Code
Note |
---|
Code Block |
Code Block |
using SoftArtisans.OfficeWriter.WordWriter; ... //Instantiate a new WordTemplate object WordTemplate WT = new WordTemplate(); //Open the template file WT.Open(Page.MapPath("//templates//Part2_Invoice_Template.docx")); //Create the array of header values object[] detailsArray = { "Jane", "Doe", DateTime.Now.ToString("MM/dd/yy"), "13139.51", "558.43", "13697.94" }; //Create the array of column names string[] detailColNames = { "FirstName", "LastName", "Date", "Subtotal", "Tax", "Total" }; //Get the order info datatable using GenericParser DataTable dtOrderInfo = GetCSVData("//data//OrderInfo.csv"); //Set the repeat block to bind the data for multiple order items WT.SetRepeatBlock(dtOrderInfo,"Repeat"); //Set the header data source to import a single row of data WT.SetDataSource(orderHeader, orderHeaderColNames, "OrderHeader"); //Process to import the data to the template WT.Process(); WT.Save(Response, "Part2_Output.docx", false); |
...