Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
710
How to create a checkbox in a colunm of a nested table and return value from database to fill it
posted

I want to create checkboxes in Row4 Col3 of the first nested table below and  fill the value of the the checkboxes from a sql server table. Can anyone share the code. Here's what I have .

using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Data.SqlClient;
using Infragistics.Web.UI.ListControls;
using Infragistics.WebUI.WebDataInput;
using System.Collections.Generic;
using Infragistics.Documents.Word;
using Infragistics.Documents.Core;
using Microsoft.Office.Interop.Word;
using Microsoft.Office.Tools.Ribbon;
using System.Drawing.Text;
using System.Drawing;
using System.IO;
using Microsoft.Office.Core;

namespace DocTemplates
{
    public partial class SCReport : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

            SqlConnection objConn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["pamdConn"].ConnectionString);
            SqlCommand objCmd;
            SqlDataAdapter objDataAdapter;

            objCmd = new SqlCommand();
            objCmd.Connection = objConn;
            objCmd.CommandType = CommandType.Text;
            objDataAdapter = new SqlDataAdapter();
            objDataAdapter.SelectCommand = objCmd;
            DataSet objDataSet = new DataSet();

            objCmd.CommandText = "Select * from tblMergedDocData";
            objDataAdapter.Fill(objDataSet, "DocData");

            // Create a new instance of the WordDocumentWriter class using the
            // static 'Create' method.
            //  This instance must be closed once content is written into Word.
            WordDocumentWriter docWriter = WordDocumentWriter.Create(@"C:\SCReport.docx");

            //  Use inches as the unit of measure
            docWriter.Unit = UnitOfMeasurement.Inch;
            //docWriter.Unit = UnitOfMeasurement.Centimeter;

            //  Create a font, which we can use in content creation
            Infragistics.Documents.Word.Font font = docWriter.CreateFont();
            //Start the document...note that each call to StartDocument must
            //be balanced with a corresponding call to EndDocument.
            docWriter.StartDocument();
            ParagraphProperties paraformat = docWriter.CreateParagraphProperties();
            paraformat.Alignment = ParagraphAlignment.Center;
            docWriter.StartParagraph(paraformat);

            //  Add a text run for the title, bolded and a little bigger
            font.Bold = true;
            font.Size = .23f;
        
            docWriter.AddTextRun("REPORT", font);
            docWriter.EndParagraph();

            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .16f;

            //docWriter.AddTextRun("To Be Completed by ", font);
            docWriter.AddTextRun("To Be Completed by Mandatory Child Abuse Reporters", font);
            docWriter.AddNewLine();
            docWriter.AddTextRun("Pursuant to Penal Code Section 11166", font);
            docWriter.AddNewLine();
            docWriter.AddTextRun("Case Name:_____________________       Case Number:_____________________", font);
            docWriter.AddNewLine();

            //End the paragraph
            docWriter.EndParagraph();

            ///////////////////////////Table1///////////////////////////////////////////////////

            // Create border properties for Table
           TableBorderProperties borderProps = docWriter.CreateTableBorderProperties();
           borderProps.Color = System.Drawing.Color.Black;
           borderProps.Style = TableBorderStyle.Double;

           // Create table properties
            TableProperties tableProps = docWriter.CreateTableProperties();
            tableProps.Alignment = ParagraphAlignment.Center;
            tableProps.BorderProperties.Color = borderProps.Color;
            tableProps.BorderProperties.Style = borderProps.Style;
            //tableProps.PreferredWidth = .2f;
           
            // Create table row properties
            TableRowProperties rowProps = docWriter.CreateTableRowProperties();
            //Make the row a Header
            rowProps.IsHeaderRow = true;

            // Create table cell properties
            TableCellProperties cellProps = docWriter.CreateTableCellProperties();
            cellProps.TextDirection = TableCellTextDirection.Normal;
            cellProps.VerticalAlignment = TableCellVerticalAlignment.Center;
            cellProps.BackColor = Color.White;

            TableCellProperties cellPropRow1 = docWriter.CreateTableCellProperties();
            cellPropRow1.TextDirection = TableCellTextDirection.BottomToTopLeftToRight;
            //cellPropRow1.TextDirection = TableCellTextDirection.
            cellPropRow1.VerticalAlignment = TableCellVerticalAlignment.Center;
            cellPropRow1.BackColor = Color.White;


            TableCellProperties cellPropHeader = docWriter.CreateTableCellProperties();
            cellPropHeader.TextDirection = TableCellTextDirection.LeftToRightTopToBottom;
            //cellPropRow1.TextDirection = TableCellTextDirection.
            cellPropHeader.VerticalAlignment = TableCellVerticalAlignment.Top;
            cellPropHeader.BackColor = Color.LightGray;
           
            //cellPropRow1.PreferredWidth = .3f;

           
         
            // Begin a Table with 2 columns
            docWriter.StartTable(2,tableProps);
            // Begin a table row
            docWriter.StartTableRow(rowProps);
           
            // Begin Table cell for first row first column
            docWriter.StartTableCell(cellPropRow1);
            docWriter.StartParagraph();
            docWriter.AddTextRun("REPORTING PARTY");
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            //start nested tables1       
            // Begin Table cell for first row second column
            docWriter.StartTableCell(cellProps);
             #region // Nested Table

           

            docWriter.StartParagraph();
            //docWriter.AddTextRun("Nested Table");
            //docWriter.AddNewLine();
            docWriter.EndParagraph();
            docWriter.StartTable(2);
            docWriter.StartTableRow();
            cellProps.Reset();
            cellProps.BackColor = Color.AliceBlue;
           
            docWriter.StartTableCell(cellPropHeader);
           
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("NAME OF Mandatory Reporter", font);
            //docWriter.AddTextRun("Nested Table Row1 Col1");

            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("Title", font);
            //docWriter.AddTextRun(objDataSet.Tables["DocData"].Rows[0]["pLastName"].ToString());
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("Mandated Reporter Category", font);
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.EndTableRow();

            docWriter.StartTableRow();
            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun(objDataSet.Tables["DocData"].Rows[0]["pLastName"].ToString());
            docWriter.EndParagraph();
            docWriter.EndTableCell();
            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun(objDataSet.Tables["DocData"].Rows[0]["pFirstName"].ToString());
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun(objDataSet.Tables["DocData"].Rows[0]["pCity"].ToString());
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.EndTableRow();

            docWriter.StartTableRow();
            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("Reporters Business/Agency Name", font);
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("Address", font);
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("Did mandatoy reporter witness the Incident?", font);
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.EndTableRow();

            docWriter.StartTableRow();
            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun("Nested Table Row4 Col1 Mary Ryan");
            docWriter.EndParagraph();
            docWriter.EndTableCell();
            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun("Nested Table Row4 Col2 4 west drive, ventura ca");
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun("Row 4 Col2 Insert 2 checkboxes here Yes checkbox or No Checkbox");
            docWriter.EndParagraph();
            docWriter.EndTableCell();


            docWriter.EndTableRow();

            docWriter.StartTableRow();
            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("reporters Phone(daytime)", font);
            docWriter.EndParagraph();
            docWriter.EndTableCell();


            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("signiture", font);
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellPropHeader);
            docWriter.StartParagraph();
            font.Bold = true;
            font.Size = .08f;
            font.Effects.Capitalization = Capitalization.CapsOn;
            docWriter.AddTextRun("todays date", font);
            docWriter.EndParagraph();
            docWriter.EndTableCell();


            docWriter.EndTableRow();

            docWriter.StartTableRow();
            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun("Nested Table Row6 Col1");
            docWriter.EndParagraph();
            docWriter.EndTableCell();
            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun("Nested Table Row6 Col2");
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.StartTableCell(cellProps);
            docWriter.StartParagraph();
            docWriter.AddTextRun("Nested Table Row6 Col3");
            docWriter.EndParagraph();
            docWriter.EndTableCell();

            docWriter.EndTableRow();
            // For nested tables at least one paragraph must be added after adding the table within the cell.
            // The EndTable method exposes an overload that adds an empty paragraph.
            docWriter.EndTable();
            #endregion // Nested Table

            docWriter.EndTableCell();
            docWriter.EndTableRow();
            //End Nested table 1

            docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.LightGray;
              docWriter.StartTableCell(cellPropRow1);
              docWriter.StartParagraph();
              docWriter.AddTextRun("REPORT NOTIFICATION");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              //start nested tables2
              docWriter.StartTableCell(cellProps);
              #region // Nested Table
              docWriter.StartParagraph();
              //docWriter.AddTextRun("Nested Table");
              //docWriter.AddNewLine();
              docWriter.EndParagraph();
              docWriter.StartTable(2);
              docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.AliceBlue;
              docWriter.StartTableCell(cellProps);

              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.EndTableRow();
              docWriter.EndTable();

              #endregion // Nested Table
              docWriter.EndTableCell();
              docWriter.EndTableRow();
            //end Nested table2

              docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.LightGray;
              docWriter.StartTableCell(cellPropRow1);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Row3 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              //start nested tables3      
              // Begin Table cell for first row second column
              docWriter.StartTableCell(cellProps);
              #region // Nested Table
              docWriter.StartParagraph();
              //docWriter.AddTextRun("Nested Table");
              //docWriter.AddNewLine();
              docWriter.EndParagraph();
              docWriter.StartTable(2);
              docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.AliceBlue;
              docWriter.StartTableCell(cellProps);

              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col2bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col3bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col1bbbbbbbbbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col2bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();
              // For nested tables at least one paragraph must be added after adding the table within the cell.
              // The EndTable method exposes an overload that adds an empty paragraph.
              docWriter.EndTable();
              #endregion // Nested Table

              docWriter.EndTableCell();
              docWriter.EndTableRow();
             //End Nested table3
            
           
              docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.LightGray;
              docWriter.StartTableCell(cellPropRow1);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Row4 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              //start nested tables4     
              // Begin Table cell for first row second column
              docWriter.StartTableCell(cellProps);
              #region // Nested Table
              docWriter.StartParagraph();
              docWriter.EndParagraph();
              docWriter.StartTable(2);
              docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.AliceBlue;
              docWriter.StartTableCell(cellProps);

              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col2bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row1 Col3bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col1bbbbbbbbbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col2bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row3 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row4 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row4 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row4 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();
            //////////////////////////////////////////////////////
              //docWriter.StartParagraph();
              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

             // docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col2bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col3bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row6 Col1bbbbbbbbbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row6 Col2bbbbbbbbbb");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row6 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row7 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row7 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row7 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row8 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row8 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row8 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              // For nested tables at least one paragraph must be added after adding the table within the cell.
              // The EndTable method exposes an overload that adds an empty paragraph.
              docWriter.EndTable();
              #endregion // Nested Table

              docWriter.EndTableCell();
              docWriter.EndTableRow();
              //End Nested table4

              docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.LightGray;
              docWriter.StartTableCell(cellPropRow1);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Row5 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();


              docWriter.StartTableCell(cellProps);
              #region // Nested Table
              docWriter.StartParagraph();
              //docWriter.AddTextRun("Nested Table");
              //docWriter.AddNewLine();
              docWriter.EndParagraph();
              docWriter.StartTable(2);
              docWriter.StartTableRow();
              cellProps.Reset();
              cellProps.BackColor = Color.AliceBlue;
              docWriter.StartTableCell(cellProps);

              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row2 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();

              docWriter.StartTableRow();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col1");
              docWriter.EndParagraph();
              docWriter.EndTableCell();
              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col2");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.StartTableCell(cellProps);
              docWriter.StartParagraph();
              docWriter.AddTextRun("Nested Table Row5 Col3");
              docWriter.EndParagraph();
              docWriter.EndTableCell();

              docWriter.EndTableRow();
              // For nested tables at least one paragraph must be added after adding the table within the cell.
              // The EndTable method exposes an overload that adds an empty paragraph.
              docWriter.EndTable();
              #endregion // Nested Table

              docWriter.EndTableCell();
              docWriter.EndTableRow();


           docWriter.EndTable();


            // Set page attributes
            SectionProperties secProperties = docWriter.CreateSectionProperties();
            secProperties.PageSize = new System.Drawing.SizeF(9, 11);
            secProperties.PageOrientation = PageOrientation.Portrait;
            // Applies the section properties(PageSize and Orientation) for the above added paragraphs
           docWriter.DefineSection(secProperties);

            // End the Document
            docWriter.EndDocument();
            // Close the writer
            docWriter.Close();

 

        }
    }
}