private void MailMerge_IncludeTextMerging(object sender,
                                                  TXTextControl.DocumentServer.MailMerge.IncludeTextMergingEventArgs e)
        {
            // custom handing of XLSX files
            switch (Path.GetExtension(e.IncludeTextField.Filename))
            {
            case ".xlsx":     // Excel file detected

                if (!File.Exists(e.IncludeTextField.Filename))
                {
                    return;
                }

                // load document into temp. ServerTextControl
                using (TXTextControl.ServerTextControl tx =
                           new TXTextControl.ServerTextControl())
                {
                    tx.Create();

                    // Bookmark name is the sheet name of the Excel document
                    TXTextControl.LoadSettings ls = new TXTextControl.LoadSettings()
                    {
                        DocumentPartName = e.IncludeTextField.Bookmark
                    };

                    try
                    {
                        // load the Excel document
                        tx.Load(
                            e.IncludeTextField.Filename,
                            TXTextControl.StreamType.SpreadsheetML,
                            ls);
                    }
                    catch {
                        return;
                    }

                    byte[] data;

                    // save the document using the TX format
                    tx.Save(out data,
                            TXTextControl.BinaryStreamType.InternalUnicodeFormat);

                    e.IncludeTextDocument = data;     // pass back to the field
                }

                break;
            }
        }
        private void mailMerge1_IncludeTextMerging(object sender, TXTextControl.DocumentServer.MailMerge.IncludeTextMergingEventArgs e)
        {
            byte[] data;

            // create blank document as byte array
            using (TXTextControl.ServerTextControl tx = new TXTextControl.ServerTextControl())
            {
                tx.Create();
                tx.Save(out data, TXTextControl.BinaryStreamType.InternalUnicodeFormat);
            }

            // remove the include text field in case the data contains a "0"
            if (ds.Tables[0].Rows[iCurrentDataRow][e.Filename].ToString() == "0")
            {
                e.IncludeTextDocument = data;
            }
        }