GroupDocs.Parser for .NET

Extract tables from DOCX using C#

Quickly identify and extract table structures from PDF, Word, Excel, and other file formats using GroupDocs.Parser in your .NET projects.

Steps to extract tables from Docx in C#

Follow these instructions to extract tables from DOCX files using GroupDocs.Parser within your .NET environment:

  1. Initialize a Parser instance and load your DOCX document.
  2. Check if table extraction is supported for the input format.
  3. Extract table content from the file.
  4. Use the structured table data for reporting, automation, or analytics.
// Open the document that contains table data using Parser
using (Parser parser = new Parser("input.docx")) {

    // Check if the format supports table recognition
    if (!parser.Features.Tables) {
        Console.WriteLine("Handle documents that do not support table parsing");
        return;
    }

    // Define how table structure should be recognized
    TemplateTableLayout layout = new TemplateTableLayout(
        new double[] { 50, 95, 275, 415, 485, 545 },
        new double[] { 325, 340, 365, 395 });

    // Specify extraction parameters for table data
    PageTableAreaOptions options = new PageTableAreaOptions(layout);

    //  Extract tables from the file content
    IEnumerable<PageTableArea> tables = parser.GetTables(options);

    //  Loop through each detected table
    foreach (PageTableArea t in tables)
    {
    }
}
dotnet add package GroupDocs.Parser
click to copy
copied
More examples Documentation

Powerful data extraction capabilities

In addition to table parsing, GroupDocs.Parser can extract rich content such as text blocks, images, metadata, and other structured data to facilitate document automation.

Table recognition and content extraction

Accurate multi-format table detection

Extract tabular data from DOCX, XLSX, PDF, HTML, and similar formats with high precision.

Parse table structures from files

Efficiently retrieve table data from documents and spreadsheets without formatting loss.

Flexible table extraction configuration

Adjust layout detection, column alignment, and header/footer options for precise control over output.

How to extract tables from Excel spreadsheets

This code sample shows how to read and iterate through table data in an XLSX file using GroupDocs.Parser.

C#

//  Open the Excel file using the Parser API
using (Parser parser = new Parser("input.xlsx"))
{
    // Exit if tables cannot be extracted from the file
    if (!parser.Features.Tables)
    {
        return;
    }

    // Use layout rules to locate tabular content
    TemplateTableLayout layout = new TemplateTableLayout(
            new double[] { 50, 95, 275, 415, 485, 545 },
            new double[] { 325, 340, 365, 395 });

    // Set up extraction parameters for tables
    PageTableAreaOptions options = new PageTableAreaOptions(layout);

    // Perform the table extraction operation
    IEnumerable<PageTableArea> tables = parser.GetTables(options);

    // Go through each detected table structure
    foreach (PageTableArea t in tables)
    {
        // Iterate through each row in the table
        for (int row = 0; row < t.RowCount; row++)
        {
            // Loop through the cells in each row
            for (int column = 0; column < t.ColumnCount; column++)
            {
                // Access the current table cell
                PageTableAreaCell cell = t[row, column];
                if (cell != null)
                {
                    // Display the text content of each cell
                    Console.Write(cell.Text);
                    Console.Write(" | ");
                }
            }
        }
    }
}

About GroupDocs.Parser for .NET API

GroupDocs.Parser is a comprehensive document parsing API built for .NET developers. It enables accurate extraction of text, tables, images, hyperlinks, and other structured elements from formats like PDF, DOCX, XLSX, PPTX, and many others — without the need for third-party software.
Learn more
About illustration

Ready to get started?

Download GroupDocs.Parser for free or get a trial license for full access!

Useful resources

Explore documentation, code samples, and community support to enhance your experience.

Supported formats for table extraction

GroupDocs.Parser can extract table data from a variety of document types. Below are the most frequently used formats for structured table parsing.

Temporary license tips

1
Sign up with your work email.
Free mail services are not allowed.
2
Use Get a temporary license button on the second step.
 English