We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. (Last updated on : Nov 16th 2018).
Unfortunately, activation email could not send to your email. Please try again.
Syncfusion Feedback

MailMerge - Repeat Header Row along with table row

Thread ID:

Created:

Updated:

Platform:

Replies:

107812 Mar 19,2013 03:28 AM UTC Mar 25,2013 01:14 PM UTC WPF 1
loading
Tags: DocIO
Carol Greenberg
Asked On March 19, 2013 03:28 AM UTC

I'm using DOC/IO to generate a report in WPF. I have a table with a Header Row and a row beneath it. Each row represents a data record in the database.

Is there a way to to have the header row repeat for each instance of the data record?

Below is the code for the mail merge, and attached is an image showing the Current Format that reflects the code below, and the New Format that I wish to display.

------------ code begins here --------------------------
public WtBpSolution( string Name, string ObjectName, string ReportBitMapFullPathName, DateTime StartDate, DateTime EndDate, Patient CurrentPatient, PDUser CurrentUser, object ParamObject )
{
try
{
this.Name                     = Name;
this.StartDate                = StartDate;
this.EndDate                  = EndDate;
this.CurrentPatient           = CurrentPatient;
this.ObjectName               = ObjectName;
this.CurrentUser              = CurrentUser;
this.ReportBitMapFullPathName = ReportBitMapFullPathName;
}
catch( Exception )
{
throw;
}
}

/// <summary>
/// 
/// </summary>
/// <param name="AbsoluteFullPathTemplateLocation"></param>
/// <returns></returns>
public override PdfDocument RunReportPDFOutFromWordTemplate( string AbsoluteFullPathTemplateLocation )
{
try
{
bool GetCycleData = true;

string PatientWeightKgs = null;
string PatientWeightLbs = null;
string BodyTemperatureCelsius = null;
string BodyTemperatureFahrenheit = null;

double BloodGL_MMOLL = 0.0;
double BloodGL_MGDL = 0.0;

List<WtBpSolutionData> DataList = new List<WtBpSolutionData>();
ObservableCollection<Treatment> Treatments = Treatment.PatientForDateRange( this.CurrentPatient.PatientIDInternal, this.StartDate, this.EndDate, GetCycleData );
if( Treatments != null && Treatments.Count > 0 )
{
foreach( Treatment t in Treatments )
{
if( t.PatientWeight < 0 )
{
PatientWeightKgs = Math.Round( ( t.PatientWeight - ApplicationConstant.SI_UNIT_OFFSET ) / 10.0, 2 ).ToString();
PatientWeightLbs = Math.Round( ( t.PatientWeight * ApplicationConstant.KG_TO_LB ) / 10.0, 2 ).ToString();
}
else
{
PatientWeightKgs = Math.Round( t.PatientWeight * ApplicationConstant.LB_TO_KG, 2).ToString();
PatientWeightLbs = t.PatientWeight.ToString();
}

if( t.Therapy >= 5 )
{
PatientWeightKgs = Math.Round( PatientWeightKgs.ToDouble() / 10.0, 2 ).ToString();
PatientWeightLbs = Math.Round( PatientWeightLbs.ToDouble() / 10.0, 2 ).ToString();

if( t.BodyTemp < 0 )
{
BodyTemperatureFahrenheit = Math.Round( Utils.C_TO_F( ( t.BodyTemp - ApplicationConstant.SI_UNIT_OFFSET ) / 10.0 ), 1 ).ToString();
BodyTemperatureCelsius = Math.Round( t.BodyTemp / 10.0, 1 ).ToString();
}
else
{
BodyTemperatureFahrenheit = Math.Round( t.BodyTemp / 10.0, 1 ).ToString();
BodyTemperatureCelsius = Math.Round( Utils.F_TO_C( ( t.BodyTemp / 10.0 ) ), 1 ).ToString();
}

if( t.BloodGl < 0 )
{
BloodGL_MMOLL = Math.Round( ( ( t.BloodGl - ApplicationConstant.SI_UNIT_OFFSET ) * ApplicationConstant.MMOLL_TO_MGDL ) / 10.0, 1 );
BloodGL_MGDL = Math.Round(t.BloodGl / 10.0, 1 );
}
else
{
BloodGL_MMOLL = Math.Round(t.BloodGl / 10.0, 1 );
BloodGL_MGDL = Math.Round( ( t.BloodGl * ApplicationConstant.MGDL_TO_MMOLL ) / 10.0, 1 );
}
}
else
{
BodyTemperatureCelsius = t.BodyTemp.ToString();
BodyTemperatureFahrenheit = t.BodyTemp.ToString();

BloodGL_MMOLL = t.BloodGl;
BloodGL_MGDL = t.BloodGl;
}

DataList.Add( new WtBpSolutionData
{
ReportLogo        = this.ReportBitMapFullPathName,
PatientName       = this.CurrentPatient.Name,
Age               = this.GetAge( this.CurrentPatient.DOB ).ToString(),
ReportName        = this.Name,
PatientIDExternal = this.CurrentPatient.PatientIDExternal,
PhysicianName     = this.CurrentPatient.PhysicianName,
UserName          = this.CurrentUser.Name,
ReportDate        = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(),

TestDate                  = t.TreatmentDate.ToShortDateString(),
StartTime                 = t.FirstDrainStart.ToString(),
BloodPressureSystolic     = t.BPSystolic.ToString(),
BloodPressureDiastolic    = t.BPDiastolic.ToString(),
PatientWeightKgs          = PatientWeightKgs,
PatientWeightLbs          = PatientWeightLbs,
SolutionTypes_1           = "Dextrose 1.5%,  \t " + t.SolBagSize1.ToString() + " ml",
SolutionTypes_2           = "Dextrose 2.5%,  \t " + t.SolBagSize2.ToString() + " ml",
SolutionTypes_4           = "Dextrose 4.25%, " + t.SolBagSize3.ToString() + " ml",
LastSolutionTypeName      = Treatment.GetSolutionTypeString( t.LastSolType ),
BloodGL_MMOLL             = BloodGL_MMOLL.ToString(),
BloodGL_MGDL              = BloodGL_MGDL.ToString(),
Pulse                     = t.Pulse.ToString(),
BodyTemperatureCelsius    = BodyTemperatureCelsius,
BodyTemperatureFahrenheit = BodyTemperatureFahrenheit
} );
}
}
else
{
DataList.Add( new WtBpSolutionData
{
ReportLogo        = this.ReportBitMapFullPathName,
PatientName       = this.CurrentPatient.Name,
Age               = this.GetAge( this.CurrentPatient.DOB ).ToString(),
ReportName        = this.Name,
PatientIDExternal = this.CurrentPatient.PatientIDExternal,
PhysicianName     = this.CurrentPatient.PhysicianName,
UserName          = this.CurrentUser.Name,
ReportDate        = DateTime.Now.ToLongDateString() + " " + DateTime.Now.ToLongTimeString(),
} );
}

//
// Get a mail merge data table object
//
MailMergeDataTable mailmergeDataTable = new MailMergeDataTable( this.ObjectName, DataList );

//
// Create the word document, open it, turn off clear fields and merge the table
//
WordDocument document = new WordDocument();
document.Open( AbsoluteFullPathTemplateLocation, FormatType.Docx );
document.MailMerge.MergeField += new MergeFieldEventHandler( AlternateRows_MergeField );
document.MailMerge.MergeImageField += new MergeImageFieldEventHandler( MergeField_ProductImage );
document.MailMerge.ClearFields = false;
document.MailMerge.ExecuteGroup( mailmergeDataTable );

//
// Turn on clear fields, grab the first row of the DataList and put it into a list and pass merge non row word fields on it
//
document.MailMerge.ClearFields = true;
List<WtBpSolutionData> dl = new List<WtBpSolutionData>();
dl.Add( DataList[ 0 ] );
document.MailMerge.Execute( dl );

//
// Convert to PDF document and return
//
PdfDocument pdfDoc = new DocToPDFConverter().ConvertToPDF( document );
return pdfDoc;
}
catch( Exception )
{
throw;
}
}
}
--------- code ends here, see attached for visuals -----------------------


mailmerge_6b4efb17.zip

Siva Subramanian [Syncfusion]
Replied On March 25, 2013 01:14 PM UTC

Hi Carol, 

Thank you for using Syncfusion products. 

We have prepared the sample to illustrate your requirement to repeat the header row for each instance of the mail merge data record. Please do find the sample from the attachment. Try running the sample and let us know if this meets your requirement. 

If the given sample doesn’t meets your requirement , please provide us the sample along with the input template document which you have used to generate the word document on your side, so that we can further analyze and update you with the appropriate details. 

Please let us know if you have questions. 

Regards,

Sivasubramanian.



GenerateWord_WPF_27d9b672.zip

CONFIRMATION

This post will be permanently deleted. Are you sure you want to continue?

Sorry, An error occured while processing your request. Please try again later.

Warning Icon You are using an outdated version of Internet Explorer that may not display all features of this and other websites. Upgrade to Internet Explorer 8 or newer for a better experience.Close Icon

;