...
Csharp |
---|
void GenerateDocument(int employeeID) { //--- Query the database DataTable dt = new DataTable(); using(SqlConnection conn = new SqlConnection(connString)) { string sql = "SELECT FirstName, LastName FROM Employee"; SqlDataAdapter adpt = new SqlDataAdapter(sql, conn); adpt.Fill(dt); } //--- Use a DataTable as the data source WordTemplate wt = new WordTemplate(); wt.Open(templatePath); wt.SetRepeatBlock(dt, "BookMarkName"); wt.Process(); wt.Save(Page.Response, "RepeatBlockOutput.doc", false); } |
Vbnet |
---|
Private Sub GenerateDocument(ByVal employeeID As Integer) '--- Use a DataTable as the data source |
...
Code Sample: Mail Merge using Repeat Blocks
...