Free Support Forum - aspose.com

Problem with table borders

I have a single cell table with no borders.
I have added a line -
tbl.SetBorders(LineStyle.None, 0, System.Drawing.Color.White);

to try to get the borders on the table to clear.
I added rows, and rows had borders.

I need to work out how to remove the default borders, while still being able to add the borders to cells as needed. (So clear borders wouldn’t work)AsposeTest.zip (23.3 KB)

@conniem,

Thanks for your inquiry. Please use following line of code after creating the table to get the desired output.

In AsposeTest method:

tbl.SetBorders(LineStyle.None, 0, System.Drawing.Color.White);
AsposeDocument.Save(s + "\\result.docx");

In addTable method:

AsposeCell.AppendChild(tbl);
tbl.SetBorders(LineStyle.None, 0, System.Drawing.Color.White);

Best Regards,
Tahir manzoor

right.
that didn’t work-
it cleared all the borders in the table - see attached (one of the cells should have a bottom border)AsposeTest.zip (30.9 KB)

@conniem,

Thanks for your inquiry. Please manually create your expected Word document using Microsoft Word and attach it here for our reference. We will investigate how you want your final Word output be generated like. We will then provide you more information on this along with code.

Best Regards,
Tahir manzoor

Basically, I would expect there to be a way to add rows to a table without lines, unless I specify them.
is there a way to do that?

in this tons of legacy code, which I am working to convert, I am trying to work out how to add rows to a table, and have the rows NOT have borders…

clearing the borders AFTER the rows has been added is not an option, as I lose specific cell borders.

@conniem,

Thanks for your inquiry. The CellFormat.Borders property returns a collection of borders of the cell and Border class represents a border of an object. You can specify the border of a cell according to your requirement. Please check following code snippet. Hope this helps you.

cell.CellFormat.Borders.Top.LineStyle = LineStyle.None;
cell.CellFormat.Borders.Bottom.LineStyle = LineStyle.None;
cell.CellFormat.Borders.Left.LineStyle = LineStyle.None;
cell.CellFormat.Borders.Right.LineStyle = LineStyle.None;

Best Regards,
Tahir Manzoor

I understand that.
what I am trying to accomplish:
I have tables that I am adding rows to.
those rows keep having borders.
even when I set the table borders to ‘none’ style.
I can’t clear the table borders when I am done adding rows, because some of the cells WILL have borders.
Is there a way to have the rows inherit properties from the table, like, borders and fonts, at the time the rows are being added to the table?

@conniem,

Thanks for your inquiry. In this case, you can clone the row and add it to the table. After adding row, remove cell’s content and add new content according to your requirement.

If you still face problem, please share your expected output Word document here for our reference. We will then provide you more information on this along with code.

Best Regards,
Tahir manzoor