Free Support Forum - aspose.com

Uregent Help ME!

Hai,

This is radha from Singapore.

I attached my code for Seperating Indivaidual Documents(One Record per Document).Now Iam using Dataset.
I need Seperate Documents for putting into one folder.For Displaying I need One Document(One Record Per page) .
While using,Dataset its displaying different records.But In that Doccument Same Record Only displaying means alldocuments has same content.


string strTemplateFile =Request.PhysicalApplicationPath + “Reminders/Templates/”+ StrReportName;

string strDatafile =Request.PhysicalApplicationPath + “Reminders/Data/”+ StrReportName.Replace(".doc",".dat").Trim();

string strMMfile =Request.PhysicalApplicationPath + “Reminders/RemindersOutput/”+ StrReportName;

string strMMdispFile = Request.PhysicalApplicationPath + “Reminders/RemindersOutput/”+ StrReportName;

Word word = new Word();

Document doc = word.Open(strTemplateFile);

DataSet DSMM= ClsRmdr.GetMMData();

for ( i = 0; i< Convert.ToInt32(DSMM.Tables[0].Rows.Count) ; i++)

{

StrSplit ="";

string SysDate = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Trans_Date”].ToString()).ToString(“dd/MM/yyyy”);

string PersonName = DSMM.Tables[0].RowsIdea[“Person_Name”].ToString();

string DeptName = DSMM.Tables[0].RowsIdea[“Dept_Name”].ToString();

string HRN = DSMM.Tables[0].RowsIdea[“HRN_ID”].ToString();

string PatName = DSMM.Tables[0].RowsIdea[“Pat_Name”].ToString();

string ReqName = DSMM.Tables[0].RowsIdea[“Req_Name”].ToString();

string RptName = DSMM.Tables[0].RowsIdea[“Rpt_Name”].ToString();

string Date1 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Date1”].ToString()).ToString(“dd/MM/yyyy”);

string Date2 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Date2”].ToString()).ToString(“dd/MM/yyyy”);

string Date3 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea[“Date3”].ToString()).ToString(“dd/MM/yyyy”);

strMMfile =Request.PhysicalApplicationPath + “Reminders/RemindersOutput/”;

StrSplit = StrReportName.Substring(0,(StrReportName.Length)-4);

if (i == 0)

{

StrSplit = StrSplit + “-01”+".doc";

strMMfile = strMMfile + StrSplit;

}

else

{

Count = Count + 1;

StrSplit = StrSplit + “-0” + Convert.ToString(Count)+".doc";

strMMfile = strMMfile + StrSplit;

}

if (RDOC01.Checked == true)

doc.MailMerge.Execute(

new string[] {“SysDate”,“DocName”,“DeptName”,“PatName”,“HRN”,“Req”,“RptName”,“DesDate”,“DueDate”,“EndDate”,“DueDate1”},

new object[] {SysDate,PersonName,DeptName,PatName,HRN,ReqName,RptName,Date1,Date2,Date1,Date3});

//In the above line displaying different name,but merging with different name.//For
Ex Person Name its displaying as “JANAk Jo”.But it mail merge with previous Record Data “NAIR”

doc.Save(strMMfile, SaveFormat.FormatDocument);

}



Can you please help me.I need to do with in this week.

When you mail merge into a document once, the mail merge fields in the document are REPLACED with values so if you try to execute mail merge second time for the same fields, nothing will happen and the second document will be simply the same as the first produced document.

Just move this code

Document doc = word.Open(strTemplateFile);

to be INSIDE the loop so the template document is opened for every record.

Hi,
Thanks a lot.I need another help from your side

Now I can able to create individual documents for that records using Dataset.I need to use the same Dataset,and create the One document but Different pages.Different Record per page.I tried the same Datset.I couldn't do.Please help me





string strTemplateFile =Request.PhysicalApplicationPath + "Reminders/Templates/"+ StrReportName;

string strDatafile =Request.PhysicalApplicationPath + "Reminders/Data/"+ StrReportName.Replace(".doc",".dat").Trim();

string strMMfile =Request.PhysicalApplicationPath + "Reminders/RemindersOutput/"+ StrReportName;

string strMMdispFile = Request.PhysicalApplicationPath + "Reminders/RemindersOutput/"+ StrReportName;

Word word = new Word();

DataSet DSMM= ClsRmdr.GetMMData();

for ( i = 0; i< Convert.ToInt32(DSMM.Tables[0].Rows.Count) ; i++)

{

StrSplit ="";

SysDate = Convert.ToDateTime(DSMM.Tables[0].RowsIdea["Trans_Date"].ToString()).ToString("dd/MM/yyyy");

PersonName = DSMM.Tables[0].RowsIdea["Person_Name"].ToString();

DeptName = DSMM.Tables[0].RowsIdea["Dept_Name"].ToString();

HRN = DSMM.Tables[0].RowsIdea["HRN_ID"].ToString();

PatName = DSMM.Tables[0].RowsIdea["Pat_Name"].ToString();

ReqName = DSMM.Tables[0].RowsIdea["Req_Name"].ToString();

RptName = DSMM.Tables[0].RowsIdea["Rpt_Name"].ToString();

Date1 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea["Date1"].ToString()).ToString("dd/MM/yyyy");

Date2 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea["Date2"].ToString()).ToString("dd/MM/yyyy");

Date3 = Convert.ToDateTime(DSMM.Tables[0].RowsIdea["Date3"].ToString()).ToString("dd/MM/yyyy");

strMMfile =Request.PhysicalApplicationPath + "Reminders/RemindersOutput/";

StrSplit = StrReportName.Substring(0,(StrReportName.Length)-4);

if (i == 0)

{

StrSplit = StrSplit + "-01"+".doc";

strMMfile = strMMfile + StrSplit;

}

else

{

Count = Count + 1;

StrSplit = StrSplit + "-0" + Convert.ToString(Count)+".doc";

strMMfile = strMMfile + StrSplit;

}

Document doc = word.Open(strTemplateFile);

doc.MailMerge.Execute(new string[] {"SysDate","DocName","DeptName","PatName","HRN","Req","RptName","DesDate","DueDate","EndDate","DueDate1"},

new object[] {SysDate,PersonName,DeptName,PatName,HRN,ReqName,RptName,Date1,Date2,Date3,Date1});

doc.Save(strMMfile, SaveFormat.FormatDocument);

}

This Dataset iam using for Individual Document.Is it possible to use Same Dataset
for using One Document with Different pages.
Please Help me .

To have many records mail merge into one document, you need to use
MailMerge.Execute(DataTable), not MailMerge(string[], object[])

hi,
Thanks Roman.Iam using Datatable.I will check the licence in our client place.
Now iam using Aspose 1.6.3.
Any new Fetures in Latest version.
Bye.

Latest is 1.8.3 at the moment. If anything, then use the latest as it least should be more stable.