Creating a table report

Table reports display 1-dimensional, not hierarchical data in tabular form. Typically, the data that is used to merge a table report is stored in a single DataTable.

This concept is used to present product lists, check lists or inventory items in a flat table form.

Demo

Include in reportCompany NameCustomer ID
A Bike Store1
Progressive Sports2
Advanced Bike Components3
Modular Cycle Systems4
Metropolitan Sports Supply5
Aerobic Exercise Company6
Associated Bikes7
Exemplary Cycles8
Tandem Bicycle Store9
Rural Cycle Emporium10
Sharp Bikes11
Bikes and Motorbikes12
Country Parts Shop13
Bicycle Warehouse Inc.14
Budget Toy Store15

The fundamental idea of 'flow type layout reporting' is to separate business logic and formatting. Data shaping and sorting is done in your data source and MailMerge receives 'merge-ready' data.

Sources

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace tx_aspnet_samples.Reporting
{
    public partial class table : System.Web.UI.Page
    {
        private TXTextControl.DocumentServer.MailMerge mailMerge1;
        private TXTextControl.ServerTextControl serverTextControl1;
        private System.ComponentModel.IContainer components;

        protected void Page_Load(object sender, EventArgs e)
        {
            InitializeComponent();

            // update GridView only once
            if (!IsPostBack)
            {
                DataSet ds = new DataSet();
                ds.ReadXml(Server.MapPath("/datasource/sample_db.xml"), 
                    XmlReadMode.Auto);

                GridView1.DataSource = ds.Tables["Customer_Customer"];
                GridView1.DataBind();
            }
        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            // load data source from sample XML DB
            DataSet ds = new DataSet();
            ds.ReadXml(Server.MapPath("/datasource/sample_db.xml"), XmlReadMode.Auto);

            // loop through GridView rows and remove unchecked from data source
            foreach (GridViewRow row in GridView1.Rows)
            {
                if (((CheckBox)row.FindControl("CheckBox1")).Checked == false)
                    ds.Tables["Customer_Customer"].
                        Rows.Remove(ds.Tables["Customer_Customer"].
                        Rows.Find(row.Cells[2].Text));
            }

            // load the template
            mailMerge1.LoadTemplate(Server.MapPath("/documents/template_table.docx"),
                TXTextControl.DocumentServer.FileFormat.WordprocessingML);
            
            // merge block data and call Merge to start the merging process
            mailMerge1.MergeBlocks(ds);
            mailMerge1.Merge(null);

            byte[] data;

            // save the document to memory as PDF
            mailMerge1.SaveDocumentToMemory(out data,
                TXTextControl.BinaryStreamType.AdobePDF, null);

            // return the document to the browser for download
            Response.Clear();
            Response.AddHeader("content-disposition",
                String.Format("attachment;filename={0}", "created_by_txtextcontrol.pdf"));
            Response.ContentType = "application/pdf";
            Response.BinaryWrite(data);
            Response.End();

        }
    }
}

Mail Merge - Reporting