Search code examples
c#migradoc

Does not contain a definition for "table" and no extension method "table" accepting


I'm trying to send data to PDF using MigraDoc. But I encountered this syntax error and could find the assembly reference to fix it.
Reason of the error is below:

        this.table = section.AddTable();
        this.table.Style = "Table";
        this.table.Borders.Color = TableBorder;
        this.table.Borders.Width = 0.25;
        this.table.Borders.Left.Width = 0.5;
        this.table.Borders.Right.Width = 0.5;
        this.table.Rows.LeftIndent = 0;

'table' is the problem here.
I'm stuck here any help would be appreciated.


Solution

    1. You haven't declared an instance field named table
    2. Or, perhaps you declared a local variable instead, in which case just remove this..
    3. Or, if you haven't declared either, change this.table = section.AddTable() to var table = section.AddTable(); and remove this. from the other statements.