Learn how to Extract Text from OneNote Tables using C#
Created
October 30, 2025 04:18
-
-
Save aspose-com-gists/f8e075073f73a1817ea742d95784f8f4 to your computer and use it in GitHub Desktop.
Extract Text from OneNote Tables
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Aspose.Note; | |
| // Load the document into Aspose.Note. | |
| Document document = new Document("SampleTable.one"); | |
| // Get a list of table nodes | |
| IList<Table> nodes = document.GetChildNodes<Table>(); | |
| // Set table count | |
| int tblCount = 0; | |
| foreach (Table table in nodes) | |
| { | |
| tblCount++; | |
| Console.WriteLine("Table # " + tblCount); | |
| // Retrieve text | |
| string text = string.Join(Environment.NewLine, | |
| table.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine; | |
| // Print text on the output screen | |
| Console.WriteLine(text); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Aspose.Note; | |
| // Load the document into Aspose.Note. | |
| Document document = new Document("SampleTable.one"); | |
| // Get a list of table nodes | |
| IList<Table> nodes = document.GetChildNodes<Table>(); | |
| foreach (Table table in nodes) | |
| { | |
| // Iterate through table rows | |
| foreach (TableRow row in table) | |
| { | |
| // Get list of TableCell nodes | |
| IList<TableCell> cellNodes = row.GetChildNodes<TableCell>(); | |
| // Iterate through table cells | |
| foreach (TableCell cell in cellNodes) | |
| { | |
| // Retrieve text | |
| string text = string.Join(Environment.NewLine, | |
| cell.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine; | |
| // Print text on the output screen | |
| Console.WriteLine(text); | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| using Aspose.Note; | |
| // Load the document into Aspose.Note. | |
| Document document = new Document("SampleTable.one"); | |
| // Get a list of table nodes | |
| IList<Table> nodes = document.GetChildNodes<Table>(); | |
| // Set row count | |
| int rowCount = 0; | |
| foreach (Table table in nodes) | |
| { | |
| // Iterate through table rows | |
| foreach (TableRow row in table) | |
| { | |
| rowCount++; | |
| // Retrieve text | |
| string text = string.Join(Environment.NewLine, | |
| row.GetChildNodes<RichText>().Select(e => e.Text)) + Environment.NewLine; | |
| // Print text on the output screen | |
| Console.WriteLine($"Row #{rowCount}:"); | |
| Console.WriteLine(text); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment