Call Features.Text property to check if text extraction is supported;
Call Features.Toc property to check if table of contents extraction is supported;
Call GetToc method and obtain collection of tables;
Iterate through the collection and get a text from tables.
The following example shows how to extract data from Sqlite database:
// Create DbConnection objectDbConnectionconnection=newSQLiteConnection(string.Format("Data Source={0};Version=3;",Constants.SampleDatabase));// Create an instance of Parser class to extract tables from the databaseusing(Parserparser=newParser(connection)){// Check if text extraction is supportedif(!parser.Features.Text){Console.WriteLine("Text extraction isn't supported.");return;}// Check if toc extraction is supportedif(!parser.Features.Toc){Console.WriteLine("Toc extraction isn't supported.");return;}// Get a list of tablesIEnumerable<TocItem>toc=parser.GetToc();// Iterate over tablesforeach(TocItemiintoc){// Print the table nameConsole.WriteLine(i.Text);// Extract a table content as a textusing(TextReaderreader=parser.GetText(i.PageIndex.Value)){Console.WriteLine(reader.ReadToEnd());}}}
Extract data with connection string
Warning
This functionality is supported only in .NET Framework version of GroupDocs.Parser for .NET
To create an instance of Parser class to extract data from a database with a connection string the following constructor is used:
Parser(stringfilePath,LoadOptionsloadOptions);
The list of tables is represented as table of contents. The table extraction is processed by GetText(int) method.
Here are the steps to extract data from Sqlite database:
Call Features.Text property to check if text extraction is supported;
Call Features.Toc property to check if table of contents extraction is supported;
Call GetToc method and obtain collection of tables;
Iterate through the collection and get a text from tables.
The following example shows how to extract data from Sqlite database:
stringconnectionString=string.Format("Provider=System.Data.Sqlite;Data Source={0};Version=3;","database.db");// Create an instance of Parser class to extract tables from the database// As filePath connection parameters are passed; LoadOptions is set to Database file formatusing(Parserparser=newParser(connectionString,newLoadOptions(FileFormat.Database))){// Check if text extraction is supportedif(!parser.Features.Text){Console.WriteLine("Text extraction isn't supported.");return;}// Check if toc extraction is supportedif(!parser.Features.Toc){Console.WriteLine("Toc extraction isn't supported.");return;}// Get a list of tablesIEnumerable<TocItem>toc=parser.GetToc();// Iterate over tablesforeach(TocItemiintoc){// Print the table nameConsole.WriteLine(i.Text);// Extract a table content as a textusing(TextReaderreader=parser.GetText(i.PageIndex.Value)){Console.WriteLine(reader.ReadToEnd());}}}
More resources
GitHub examples
You may easily run the code above and see the feature in action in our GitHub examples:
Along with full featured .NET library we provide simple, but powerful free Apps.
You are welcome to parse documents and extract data from PDF, DOC, DOCX, PPT, PPTX, XLS, XLSX, Emails and more with our free online Free Online Document Parser App.
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.