Invisible cell borders

Hi support,

I have a question regarding table borders. I’m reading the content of a Word document. I parse through nodes and save their formatting properties.
In this document I have a table that has only the table borders set (the cells appear like they do not have borders), and cell spacing set also. The issue is that, by using code, I get that the cells near the edge of the table have the adjacent borders set.
After reading the document I try to build a similar document based on the collected data. Instead of a table with table borders set only, I obtain a table that seems to have two parallel borders; it looks like two embedded squares, because the cell borders near the edge of the table borders are set also.

I’ve noted in MS Word, within the document I read, that those cells have the specific borders set, (table properties->borders and shading->cell), but they are not visible.
Also noted that for those borders the “isInherited()” method returns false. I’ve made a test considering the result of that method and obtained desired result. It is a method reserved for internal use, as your documentation says, so I would like to know if it’s safe to use it as I intend to.

Please advice,
Milan

Hi Milan,

Thanks for your request. Could you please attach your source and output documents? I will check the issue and provide you more information.
Best regards.

Hi Alexy,

I attach the source document and the one that I obtain without using isInherited() method (the souce code is pretty big, so I didn’t attached). For the top border of the last cell in 1st row, the method isInherited() returns false, so if I use it to decide if I apply the data received for that top border, I do obtain expected result (like the original).

Here is the decision block that solves the issue:

if (!cellReaded.getCellFormat().getBorders().getTop().isInherited())
{
    cellWritten.getCellFormat().getBorders().getTop().setLineStyle(cellReaded.getCellFormat().getBorders().getTop().getLineStyle());
    cellWritten.getCellFormat().getBorders().getTop().setColor(cellReaded.getCellFormat().getBorders().getTop().getColor());
    cellWritten.getCellFormat().getBorders().getTop().setLineWidth(cellReaded.getCellFormat().getBorders().getTop().getLineWidth());
}

I just need a confirmation that the solution with “isInherited()” method is the best approach.

Regards,
Milan

Hi Milan,

Thanks for your request. You are right isInherited property is reserved for internal use only. But, I think, if it is useful in your case, you can use it. Also, I think, the main problem in your case is that currently, Aspose.Words does not support table format. So you cannot specify border around table as you can do in MS Word. I linked your request to the appropriate issue. You will be notified as soon as this feature is added.
Best regards.

Hi Alexey,

Unfortunately, after some little testing, the method is not helpful. It returns same result (true) when cell border is visible or not (I make the cell border invisible in MS Word by deselecting horizontal and vertical table borders). It returns false only when cell border is explicitly set by the user.

I’ll attach the code I’m using, and the modified documents.

Thank you for looking into this,
Milan

Hi Milan,

Thank you for additional information. Could you please explain, why you need to recreate table in the other document? Maybe it would be easier just import whole table into the destination document.
It is difficult and sometimes impossible to recreate node with the same formatting as the original using attributes exposed by Aspose.Words. The reason for this is that Aspose.Words does not expose original collections of formatting attributes in the public API, but allows access to only fully calculated values.
Best regards.

Hi Alexey,

Thank you for the promptitude.
I cannot just import the table into the destination document, because extra processing is needed on most of the cases, depending on the table content. Thus, the two tables are not always similar (at least, their content). But in this particular case, the intention is to make the result table like the source table, because the extra processing is not necessary here.

Please confirm if my request regarding borders is possible by using current API .

Regards,
Milan

Hi Milan,

Thanks for your request. I did not manage to recreate the same table using properties, which were read from the original document. Most likely, there is some complex inheritance of borders formatting, which cannot be recreated using properties exposed by Aspose.Words.
As a workaround, I can suggest you to import whole table into the destination document and perform post-processing of this table. Please let me know if you need assistance in achieving the same. I will be glad to help you.
Best regards.

The issues you have found earlier (filed as WORDSNET-581) have been fixed in this .NET update and in this Java update.

This message was posted using Notification2Forum from Downloads module by aspose.notifier.
(54)