Free Support Forum - aspose.com

Insert footer only on last page

hi all...I have a question for you: I want to insert header and footer section on a document with many pages...I had created a DOT model within a header and footer, but when I create the DOC document the header is only on first page, but the footer is in all pages, and I want to view the footer only on last page...can I do this???

this is my code:

private void btnPickOrder_Click(object sender, System.EventArgs e) {

string connectionString = "server=mssql.globalitalia.it;database=;uid=;pwd=;";

SqlConnection cn = new SqlConnection(connectionString);

cn.Open();

DataTable dt = SqlHelper.ExecuteDataset(cn, "SelectPickOrder_Cs", null).Tables[0];

int rows = dt.Rows.Count;

Aspose.Word.License licWord = new Aspose.Word.License();

licWord.SetLicense((System.IO.Stream)null);

Document allOrdersDoc;

Document oneOrderDoc;

allOrdersDoc = new Document();

allOrdersDoc.RemoveAllChildren();

for(int i = 0; i < rows; i++){

oneOrderDoc = new Document(Server.MapPath("Dot/Report.dot"));

int pickOrderId = int.Parse(dt.RowsIdea [I].ItemArray.GetValue(0).ToString());

object[] parameters = {pickOrderId};

DataTable dtRow = SqlHelper.ExecuteDataset(cn, "SelectPickOrderLineByPickOrder_Cs", parameters).Tables[0];

dtRow.TableName = "PickOrderLine";

oneOrderDoc.MailMerge.ExecuteWithRegions(dtRow);

oneOrderDoc.MailMerge.Execute(dt.RowsIdea [I]);

AppendDoc(allOrdersDoc, oneOrderDoc);

}

cn.Close();

string path = Server.MapPath("Dot/Ordini.doc");

allOrdersDoc.Save(path);

}

private void AppendDoc(Document dstDoc, Document srcDoc) {

for(int i = 0; i < srcDoc.Sections.Count; i++) {

Aspose.Word.Section section = (Aspose.Word.Section)dstDoc.ImportNode(srcDoc.SectionsIdea [I], true);

dstDoc.Sections.Add(section);

}

}

Please help me because is urgently...THANKS!!!

HI!!!

P.S. I attach my DOT model

There does not seem to be any footer in Report.dot. Only header is present.

sorry…now the dot is ok…Wink [;)]

i attach the DOC file generated with DOT.

for example the header "ID: 2"...the rows go to 2 pages and the footer is visible in all page, i want to see the footer only on last page of a ID...

Is all right?

MS Word have only the following settings for headers and footers:

Different odd and even

Creates one header or footer for even-numbered pages and a different header or footer for odd-numbered pages.

Different first page

Creates a different header or footer for the first page of a document or a section.

Maybe you should use a footnote or endnote instead.

thanks for the answer…Smile [:)]