...
Code Block |
---|
public void GenerateDocument() { WordTemplate wt = new WordTemplate(); wt.Open(@"..\..\WordTemplateFiles\NestedCatalogTemplate.docx"); DataTable dt = new DataTable(); dt = GetCatalogData(@"..\..\WordData\NestedProductCatalogData.csv"); dt.Columns.Add("LargePhoto", typeof(byte[])); //Retrieves each picture in the NestedProductCatalogImages folder //and get a byte[] for each one using the GetCatalogPictures Helper method. //Then add this byte[] to the LargePhoto column in dt. for (int k = 0; k < dt.Rows.Count; k++) { string imageName = dt.Rows[k].ItemArray[6].ToString(); DataRow dr = dt.Rows[k]; dr[7] = GetCatalogPictures(imageName); } wt.SetDataSource(DateTime.Now, "HeaderData"); //Sets the data source for the index of the catalog with bookmark string "Index" wt.SetRepeatBlock(GetCatalogData(@"..\..\WordData\NestedProductCatalogIndexData.csv"), "Index"); //Sets the data source for the body of the catalog with bookmark string "Catalog" wt.SetRepeatBlock(dt, "Catalog"); wt.Process(); //Save the product catalog in the desired location on the disc wt.Save(@"..\..\WordOutputFiles\NestedProductCatalog_output.docx"); } |
...