Example #1
0
        public static void ProcessAndBindData(ref Document doc, DataSet reportData)
        {
            // Add a handler for the MergeField event.
            handleMergeFieldObj = new HandleMergeField();
            doc.MailMerge.FieldMergingCallback = handleMergeFieldObj;

            //Supply RichTextField name to HandleMerge class object
            //handleMergeFieldObj.RichTextFieldKeyValue = new ArrayList() { "RichText_ExecutiveSummary" };

            for (var index = 0; index < reportData.Tables.Count; index++)
            {
                DataTable dtMergeFields = reportData.Tables[index];
                if (dtMergeFields.TableName.StartsWith("Table_"))
                {
                    doc.MailMerge.ExecuteWithRegions(dtMergeFields);
                }
                else if (dtMergeFields.TableName.ToLower().StartsWith("tbl_"))
                {
                    doc.MailMerge.Execute(new string[] { dtMergeFields.TableName }, new object[] { dtMergeFields });
                }
                else
                {
                    if (!dtMergeFields.TableName.StartsWith("Chart_"))
                    {
                        doc.MailMerge.Execute(dtMergeFields);
                    }
                }
            }
            ProcessImage(doc, reportData);
            RemoveBlankPages(doc);
        }
Example #2
0
        public static void ProcessAndBindData(ref Document doc, ReportData reportData)
        {
            // Add a handler for the MergeField event.
            handleMergeFieldObj = new HandleMergeField();
            doc.MailMerge.FieldMergingCallback = handleMergeFieldObj;

            //Supply RichTextField name to HandleMerge class object
            handleMergeFieldObj.RichTextFieldKeyValue = new ArrayList()
            {
                "RichText_ExecutiveSummary"
            };

            for (var index = 0; index < reportData.NonTabularData.Tables.Count; index++)
            {
                DataTable dtMergeFields = reportData.NonTabularData.Tables[index];
                if (dtMergeFields.TableName.StartsWith("Table_"))
                {
                    doc.MailMerge.ExecuteWithRegions(dtMergeFields);
                }
                else if (dtMergeFields.TableName.ToLower().StartsWith("tbl_"))
                {
                    doc.MailMerge.Execute(new string[] { dtMergeFields.TableName }, new object[] { dtMergeFields });
                }
                else if (dtMergeFields.TableName == "SectionF")
                {
                    DataTable assessorViewtable = new DataTable();
                    if (reportData.NonTabularData.Tables.Count > 17)
                    {
                        assessorViewtable = reportData.NonTabularData.Tables[17];
                    }
                    ProcessAndBindSectionF(ref doc, dtMergeFields, reportData.TabularData, reportData.NonTabularData.Tables[15], reportData.NonTabularData.Tables[16], assessorViewtable);
                }
                else if (dtMergeFields.TableName == "Feedback_SectionD")
                {
                    ProcessAndBindSectionF(ref doc, dtMergeFields, reportData.TabularData, reportData.NonTabularData.Tables[6]);
                }
                else if (dtMergeFields.TableName == "JuryTable")
                {
                    ProcessAndBindSectionF(ref doc, dtMergeFields, reportData.TabularData, reportData.NonTabularData.Tables[2]);
                }
                else
                {
                    if (dtMergeFields.TableName != "AssessorView" && dtMergeFields.TableName != "AditionalInfo" && dtMergeFields.TableName != "Validation" && !dtMergeFields.TableName.StartsWith("chart_"))
                    {
                        doc.MailMerge.Execute(dtMergeFields);
                    }
                }
            }

            RemoveBlankPages(doc);
        }