RowFormat.Borders ignoring!



<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you very much for your help with export to HTML. It works just fine. I owe you Beer!

But now I experience a new problem.

Trying to make a border between some rows in a table thicker then others I use the next code:

private void HandleMergeGroupingField(object sender, MergeFieldEventArgs e)


if (e.FieldName == "Grouping" && e.TableName == "details_markers")





string fieldValue = e.FieldValue.ToString();

if(fieldValue == groupingName && groupingCount==0)



mBuilder.RowFormat.Borders[BorderType.Top].LineWidth = 6;




When document finally is opened no sign of the thicker border is shown. The code was ignored. No BorderTypes are supported.

Debugging brings the next:

mBuilder.RowFormat.Borders[BorderType.Top].LineWidth error: object 'mBuilder.ParagraphFormat.Borders' doesn't have an indexer

I also experimented with Indexes instead of BorderTypes, but couldn’t find any for TOP or BOTTOM. Indexes for Left, Right, Horizontal and Vertical work fine

When I tried to work with CellFormat it didn’t work at all and I couldn’t open the document.

On the Forum I saw somebody has the same problem with ParagraphFormat.

Code from your DocumentBuilderDemo doesn’t work as well.

We use MS Word 2003.

Thank you in advance and hope you will help with this issue ASAP.



Hi Igor,

1. The borders in your document are left unchanged because you are trying to use DocumentBuilder to change the existing elements. This will not work since the builder is intended for adding new elements. You should work directly with the model (nodes) that became available in Aspose.Word v3.x.

2. The error you have reported looks pretty weird. RowFormat.Borders is not related to ParagraphFormat.Borders… Anyway, both of them return a Borders object that do have the indexer. Please double check it.

3. RowFormat.Borders actually have both the top and bottom borders. Will these lines work for you:

Border border1 = mBuilder.RowFormat.Borders[BorderType.Top];
Border border2 = mBuilder.RowFormat.Borders[BorderType.Bottom];


4. Please describe what’s wrong with CellFormat and why you were unable to open the document.

5. Do you mean that you have problems with paragraph alignment in the document produced by the DocumentBuilder demo as the cudtomer in the mentioned thread? Are there any other issues?

In addition, please attach the document template you are working with, perhaps it will help us to recognize the cause of the issues and give you some hints to process the borders as you intend.



I tried CellFormat - it works. But RowFormat doesn't.
I do not quite understand what you mean by using Node. Can you explain it or send the code example?

Thanks, Igor.


Please ignore my statement related to DocumentBuilder. It is still able to change formatting of a particular existing element after the “cursor” is moved there. I am sorry for misleading.

We have discovered that attempt of setting line width of top or bottom row borders indeed fails while use of BorderType.Horizontal works fine. Could you use it while we are investigating the issue? Please however attach your document, this will surely simplify the investigation and help us to resolve the issue.

Also, are you still getting this error:

mBuilder.RowFormat.Borders[BorderType.Top].LineWidth error: object ‘mBuilder.ParagraphFormat.Borders’ doesn’t have an indexer


Please describe the details of the error, in what way it occurs, and so on. Is that a compile error or runtime exception?


This has to do with the way MS Word stores information about table rows in a binary file and the way Aspose.Word presents in the API.

Strictly speaking each row stored in a Word file is a complete table in itself and the properties you can access via RowFormat are both row and table-level formatting properties and this might cause some confusion like in your case until Aspose.Word is enhanced to expose table formatting properties separately from row formatting properties.

In the meantime, the following works:

DocumentBuilder b = new DocumentBuilder(doc);

//You can set top border of the top row using RowFormat.Borders.
b.MoveToCell(0, 0, 0, 0);
b.RowFormat.Borders[BorderType.Top].LineStyle = LineStyle.Double;
b.RowFormat.Borders[BorderType.Top].LineWidth = 4;

//You can set bottom border of the bottom row using RowFormat.Borders.
b.MoveToCell(0, -1, 0, 0);
b.RowFormat.Borders[BorderType.Bottom].LineStyle = LineStyle.Double;
b.RowFormat.Borders[BorderType.Bottom].LineWidth = 4;

//You can set both top and bottom borders of a row in the middle of a table.
b.MoveToCell(0, 1, 0, 0);
b.RowFormat.Borders[BorderType.Horizontal].LineStyle = LineStyle.Double;
b.RowFormat.Borders[BorderType.Horizontal].LineWidth = 4;

//For other situations you can use CellFormat.Borders since they override borders specified by RowFormat.Borders.
//This is how to set top borders of a row in the middle of the table:
b.MoveToCell(0, 1, 0, 0);
b.CellFormat.Borders[BorderType.Top].LineStyle = LineStyle.Double;
b.CellFormat.Borders[BorderType.Top].LineWidth = 4;

Vertical, right and left borders work in the same way.