Ciccio
November 24, 2005, 9:13am
1
hi all...
for(int x = 0 ; x < rows; x++){
Document doc = new Document(Server.MapPath("Dot/Report.dot"));
int pickOrderId = int.Parse(dt.Rows[x].ItemArray.GetValue(0 ).ToString());
object[] parameters = {pickOrderId};
DataTable dtRow = SqlHelper.ExecuteDataset(cn, "SelectPickOrderLineByForeignKey_Cs", parameters).Tables[0 ];
dtRow.TableName = "PickOrderLine";
doc.MailMerge.ExecuteWithRegions(dtRow);
doc.MailMerge.Execute(dt.Rows[x]);
doc.Save(Server.MapPath("Dot/" + dt.Rows[x].ItemArray.GetValue(1 ).ToString() + ".doc"));
}
this code create a doc file foreach row, but if i want to create only one doc file and add a new page foreach row in my DataTable what can i do?
Example:
MyDataTable.Rows.Count --> 12
My code create 12 doc file (Doc1.doc, Doc2.doc, etc...)
What can I create a page into a doc file for any lap of my "For"?
THANKS!
romank
November 24, 2005, 11:30pm
2
You need to append each of your order documents into a single document, some thing like this;
Document allOrdersDoc = new Document();
//loop to create one document per order (your code posted above) Document oneOrderDoc = ...
AppendDoc(allOrdersDoc, oneOrderDoc);
---------------
AppendDoc is a simple fuction like this:
///
/// Copies all sections from one document to another.
///
private void AppendDoc(Document dstDoc, Document srcDoc)
{
for (int i = 0; i < srcDoc.Sections.Count; i++)
{
//First need to import the section into the destination document,
//this translates any document specific lists or styles.
Section section = (Section)dstDoc.ImportNode(srcDoc.Sections , true);
dstDoc.Sections.Add(section);
}
}
romank
November 24, 2005, 11:32pm
3
This is needed because your scenario is a master-child relationship and it would require nested mail merge regions in the document to solve and Aspose.Word does not yet support nested merge regions. We will eventually support nested merge regions later and master-child mail merge will be possible with just a single line of code.
Ciccio
November 25, 2005, 2:28am
4
thank you very very much...
but I have another problem: with your code posted above whene I create the allOrdersDoc (document container), aspose create a blank page in 1st position but my orders start from 2nd page...can I delete the 1st page of document container?
Ciccio
November 25, 2005, 8:34am
6
please help me...is urgently...please...
THANKS...
romank
November 25, 2005, 12:04pm
7
Even a blank document in MS Word contains at least on section with one empty paragraph.
You can just clear the initial document completely:
doc.RemoveAllChildren();
or remove the first empty section:
doc.Sections.RemoveAt(0);
Ciccio
November 28, 2005, 3:17am
8
it's ok!!!
thank you very very much!!!
The issues you have found earlier (filed as 39) have been fixed in this update .
This message was posted using Notification2Forum from Downloads module by aspose.notifier . (103)