Get Table Cell Color

Jan 12, 2016 at 3:32 PM
I have a single .DOCX file with one table in it. Some of the cells in the table have a color, and I am trying to grab each cell color to do other stuff.

Here is the code I wrote that I thought would work. Instead, when it hits the "Color" declaration line it always generates "$exception {"Input string was not in a correct format."} System.Exception {System.FormatException}".

I am unsure what is the proper way to get the cell color. Any clues/tips/suggestions?

Thanks a lot.

The code:
static void Main( string[] args )
{
    using ( DocX document = DocX.Load( args[0] ) )
    {
        Novacode.Table table = document.Tables[0];
        
        for ( int row = 0; row < table.RowCount; row++ )
        {
            for ( int cell = 0; cell < table.Rows[ row ].Cells.Count; cell++ )
            {
                Color cellColor = table.Rows[ row ].Cells[ cell ].FillColor;
            }
        }
    }
}
Jan 12, 2016 at 3:57 PM
Just an update.

Believe the reason for the error message is some cells have no color ( I thought it was white ) so I have to figure out how to check for a nul color.