Hi all,
i work with visual studio 2012 and c# 4.0
i must to replace all rtf files locate in all our applications to aspose word
many week of works i think
i begin with your library, i’ve just to start this monday
i’d like to create a sample document with just a footer
this footer MUST BE locate at end of document (as in my sample)
this footer must be contains a sample table who have two rows with two columns …
How i can do that ?
I join the document that i want
thanks for your time and your knowledge
Christophe
Hi Christophe,
Thanks for your inquiry. Please read the following article about creating header/footer in the document.
https://docs.aspose.com/words/net/working-with-headers-and-footers/
Moreover, please use following code example to achieve your requirements. Hope this helps you.
Document doc = new Document(MyDir + "in.docx");
DocumentBuilder builder = new DocumentBuilder(doc);
builder.MoveToDocumentEnd();
Section currentSection = builder.CurrentSection;
PageSetup pageSetup = currentSection.PageSetup;
builder.MoveToHeaderFooter(HeaderFooterType.FooterPrimary);
Table table = builder.StartTable();
// Insert a cell
builder.InsertCell();
table.PreferredWidth = PreferredWidth.FromPercent(100);
builder.Write("This is row 1 cell 1");
// Insert a cell
builder.InsertCell();
builder.Write("This is row 1 cell 2");
builder.EndRow();
// Insert a cell
builder.InsertCell();
builder.Write("This is row 2 cell 1");
// Insert a cell
builder.InsertCell();
builder.Write("This is row 2 cell 2");
builder.EndRow();
builder.EndTable();
// Save the resulting document.
doc.Save(MyDir + "HeaderFooter Out.docx");
Hello tahir manzoor,
thanks for your knowledge and your time …that’s great …
just another little question
i have a long table with many datas who comes from database.
this table contains a header rows => TITLE 1 with the proprerties HeadingFormat= true
This table have border left, right, top and bottom for the first row
For other row just left and right if it’s last row i have a border bottom.
All are ok but i have just a little problem …
i have a for(int i=0; i< …) method and i loop on my all data
when a new page is added my table locate in the LAST page hasn’t a border.bottom
i have join a print screen on my generate document because my english isn’t real perfect
my question is, how i can detect the end of the page and add a border.bottom ?
many thanks guy
Hi Christophe,
Thanks for your inquiry. In case you are using older version of Aspose.Word, please use Aspose.Words for .NET 15.3.0. Hope this helps you. You may use following code example to set the bottom border of a cell.
Document doc = new Document(MyDir + "in.docx");
foreach (Cell cell in doc.GetChildNodes(NodeType.Cell, true))
{
cell.CellFormat.Borders.Bottom.LineStyle = LineStyle.Single;
cell.CellFormat.Borders.Bottom.LineWidth = 1;
}
doc.Save(MyDir + "Out.docx");
If you still face problem, please share following detail for investigation purposes.
-
Please attach your input Word document.
-
Please create a standalone/runnable simple application (for example a Console
Application Project) that demonstrates the code (Aspose.Words code) you used to generate your output document
-
Please attach the output Word file that shows the undesired behavior.
-
Please attach your target Word document showing the desired behavior. You can
use Microsoft Word to create your target Word document. I will investigate as to how you are expecting your final document be generated like.
Unfortunately, it is difficult to say what the problem is without the Document(s) and
simplified application. We need your Document(s) and simple project to
reproduce the problem. As soon as you get these pieces of information to
us we’ll start our investigation into your issue.
Hello tahir manzoor,
really thanks for your sample but my problem is this :
foreach (Cell cell in doc.GetChildNodes(NodeType.Cell, true))
{
cell.CellFormat.Borders.Bottom.LineStyle = LineStyle.Single;
if (endOfDocument == true)// => how i can do this ?
cell.CellFormat.Borders.Bottom.LineWidth = 1;
else
cell.CellFormat.Borders.Bottom.LineWidth = 0;
}
I don’t want a border BOTTOM between row …
i want a border BOTTEM just at the end of table OR when i arrive at the end of document
Sorry for my english, i know it’s too bad
Thanks at all
Christophe
Hi Christophe,
Thanks for your inquiry. Please share following detail for investigation purposes.
- Please attach your input Word document.
- Please attach the output Word file that shows the undesired behavior.
- Please attach your target Word document showing the desired behavior. You can
use Microsoft Word to create your target Word document. I will investigate as to how you are expecting your final document be generated like.
As soon as you get these pieces of information to us we’ll start our investigation into your issue.
Hello,
Here is it my sample.
my code sample and the output of the document
When you open the document, you’ll see just a table with 70 rows
There is no border bottom between rows that’s normal
I want a border bottom ONLY if we are at the end of the page or the end of the table
int maxRows = 70;
builder.StartTable();
//
builder.CellFormat.ClearFormatting();
//
builder.Font.Size = 12;
builder.Font.Bold = true;
//
builder.StartTable();
builder.CellFormat.VerticalAlignment = Aspose.Words.Tables.CellVerticalAlignment.Center;
#region title
//
BorderCollection borders;
//
borders = builder.RowFormat.Borders;
//
borders.Right.LineWidth = borderTable;
borders.Right.Color = System.Drawing.Color.Black;
//
borders.Left.LineWidth = borderTable;
borders.Left.Color = System.Drawing.Color.Black;
//
borders.Top.LineWidth = borderTable;
borders.Top.Color = System.Drawing.Color.Black;
//
builder.CellFormat.Shading.BackgroundPatternColor = System.Drawing.Color.LightGray;
builder.RowFormat.Height = 0.2 * 72;
//
builder.InsertCell();
builder.CellFormat.Width = width;
builder.Write("Title Header");
//
builder.RowFormat.HeadingFormat = true;
builder.EndRow();
#endregion
#region Datas
//
builder.CellFormat.Shading.ClearFormatting();
//
builder.RowFormat.Height = 0.2 * 72;
builder.Font.Bold = false;
builder.Font.Size = 10;
for (int i = 0; i < maxRows; i++)
{
//
builder.InsertCell();
builder.CellFormat.Borders.ClearFormatting();
builder.Write(string.Format("row : {0}", i));
builder.CellFormat.Borders.Left.LineWidth = borderTable;
builder.CellFormat.Borders.Right.LineWidth = borderTable;
//
if (i != (maxRows - 1))
builder.CellFormat.Borders.Bottom.LineWidth = 0;
else
builder.CellFormat.Borders.Bottom.LineWidth = borderTable;
//
builder.RowFormat.HeadingFormat = false;
builder.EndRow();
}
#endregion
//
builder.EndTable();
thanks for all
Christophe
Hello,
thanks for your reply and sample that’s exactly what i want …
nice …
have a nice day
Christophe
Hi Christophe,
Thanks for your feedback. Please feel free to ask if you have any question about Aspose.Words, we will be happy to help you.