Free Support Forum - aspose.com

Re: Building a table in header

Hi,

i encounter a problem in adding a table in the header. i was able to add a table into the header using this code,

//Move to the 1st page of the headers
pdocBuilder.MoveToHeaderFooter(HeaderFooterType.HeaderFirst);

// Write the heading
pdocBuilder.Writeln("Heading");
pdocBuilder.Writeln("sub heading");

// 1st row
// Title
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.First;
pdocBuilder.Writeln("Title: ");
pdocBuilder.Writeln("eric");
pdocBuilder.Writeln("test");

// Document Number
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.None;
pdocBuilder.Write("Document Number: ");
pdocBuilder.Write("321");

// Page
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.First;
pdocBuilder.Writeln("Page X of Y");
pdocBuilder.EndRow();

// 2nd row
// Revision No
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.Previous;
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.None;
pdocBuilder.Write("Revision No: ");
pdocBuilder.Write("50");
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.Previous;
pdocBuilder.EndRow();

// 3rd Row, 1st cell Issued By, Initial Date issued, Date Reviewed, Date revised
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.None;
// Issued By
pdocBuilder.Writeln("Issued by: ");
pdocBuilder.Write("eric");
// Initial Date issued
pdocBuilder.Writeln("Initial date issued: ");
pdocBuilder.Write("eric");
// Date Reviewed
pdocBuilder.Writeln("Date reviewed: ");
pdocBuilder.Write("eric");
// Date revised
pdocBuilder.Writeln("Date revised: ");
pdocBuilder.Write("eric");

// 3nd row 2nd cell merge with 3rd cell
pdocBuilder.InsertCell();
pdocBuilder.CellFormat.VerticalMerge = CellMerge.None;

// Approved by
pdocBuilder.Writeln("Approved by: ");
pdocBuilder.Writeln("eric");

pdocBuilder.InsertCell();
pdocBuilder.CellFormat.HorizontalMerge = CellMerge.Previous;

// end of 3rd row
pdocBuilder.EndRow();

pdocBuilder.EndTable();

* What happen is that , the width of the 3rd row for the table keep will not have the same width as the 1st and 2nd row.
* The other question i would like to find out is that how i add the page number object to the header
* Also how do i delete the "heading" and "subheading" in the header before the heading


Regards,
Eric Tan
Commerce Online

Please let me know if some of your questions are still not answered.


Hi Roman,

I would like to apologise for the hashness in the previous post. Yup, it does solve my problem.

But there is 1 thing which i still not too sure how to resolve, how do i clear all the content in the header and footer. Reason is that i would like to overwrite whatever header and footer in the word document that the user had added in.

Also, will the alignment of the table be out in the next version?

Regards,
Eric Tan

Both clearing headers/footers and aligning tables are good feature requests and they are on our task list already. They could be implemented in a month or two (there is a queue of other features). Can you live with that?

Hi Roman,

I see. Yup, i can live with it at the moment. Hope that these two features will be out real soon.

Thank for all the helps.

Hope that you can drop me a mail once this is out.

Regards,
Eric Tan
Commerce Online Pte Ltd

Please get latest Aspose.Word 1.9.8 as we added Section.ClearHeadersFooters. Check release notes http://www.aspose.com/blogs/roman.korchagin/archive/2004/11/23/257.aspx