Adding Sections Problem.. What am I doing wrong?


#1

We are currently testing your Aspose.Word compnent and I have a question… I have the issue of a nested table and I’m trying to add sections together as suggested by other posts in the forum. However, my problem is that every new section that is added shows up on a new page in the Word Document… in other words instead of having, say 3, short sections appended on 1 page, the Sections.Add function creates a new page for every new section. What am I doing wrong? Here’s the code that I’m using…

public void AsposeWordTest()
{
Word word = new Word();
Document docTemplate = word.Open(MapPath("~/TLSATemplate.doc"));
Document doc = word.Open(MapPath("~/TLSAHeader.doc"));

// Hard coded Date for Testing
DateTime date = new DateTime(2000, 8, 15);

// Get the DataTable from the database
Components.Database database = new Components.Database();
DataTable dt = database.GetLettingList(date);

Document memDoc = null;

foreach (DataRow dr in dt.Rows)
{
memDoc = docTemplate.Clone();

// MailMerge doesn’t allow for merging with a datarow
// so copy the current row to a new table
DataTable dtTemp = dt.Clone();
dtTemp.ImportRow(dr);

memDoc.MailMerge.Execute(dtTemp);

// Now add the new merged section to the document
Section section = memDoc.Sections[0];
memDoc.Sections.Remove(section);
doc.Sections.Add(section);
}

doc.Save(“test.doc”, SaveFormat.FormatDocument, SaveType.OpenInWord, Response);
}

Thanks,
Bruce


#2

You need to edit your document where the sections come from to make the section Continuous, not Start From New Page. For existing section it can be done in File/Page Setup/Layout.


#3

Ah, ok I’ll give that a try. Thanks!!