Shading and cell properties

Hi,

I have a table, whose cell’s backgorund color is white(255,255,255) .

I am using following code to fetch background color of the cell,

CellFormat cellFormat = cell.getCellFormat();
Shading shading = cellFormat.getShading();
Color shadeColor = shading.getBackgroundPatternColor();

The problem is that i am geeting the background color as black(0,0,0) which should ideally be white(255,255,255).

Note: if i use any other color for backgound shading of cell , i get the correct RGB code.

Thanks,

Anup

Hi Anup,

Please attach a sample document containing the table and specify what cell in what row you test in your code.

Thanks.

Hi Dmitry,

Please find the file attached. If you browse through the document you will notice a table. The cell shading information (backgound color) is not coming properly for 2nd and 3rd row.

Also i wanted to know that , if i have to insert a section into a word document what is the correct way of doing it using DocumetBuilder class.

Thanks,

Anup

Anup,

Thank you for additional info. It seems that the background cell color is not black but “auto” (ARGB(0, 0, 0, 0)), or “full transparency black”, which is a special color value used in Word to specify the default color. However, give me around a day to consult with Roman; I need to figure out whether exposing the “auto” color is a bug or feature.

Regarding your question: to insert a section into the document using DocumentBuilder, consider the InsertBreak method:
https://reference.aspose.com/words/net/aspose.words/documentbuilder/methods/insertbreak

Hi Dmitry,

Any Update.

Anup,

Please note, that the cells in the 2nd and 3rd rows of your table do not have their color set to White. If you check the Fill setting for these cells in Borders and Shading dialog you will see that it is set to No Fill. That corresponds to Color.Empty in .NET or ARGB = 0, 0, 0, 0. To get white color for these cells their shading fill should be explicitly set to White in MS Word or to Color.White using Aspose.Words API. This, however, can cause problems with visibility of table borders as was previously discussed in the following thread:
https://docs.aspose.com/words/net/working-with-tables/
Also note, that Color.Black is different from Color.Empty and its ARGB is 255, 0, 0, 0 in .NET.

Hope that clarifies things. Please let me know if you have further questions.