Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save aspose-com-gists/f8e075073f73a1817ea742d95784f8f4 to your computer and use it in GitHub Desktop.

Select an option

Save aspose-com-gists/f8e075073f73a1817ea742d95784f8f4 to your computer and use it in GitHub Desktop.
Extract Text from OneNote Tables
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);
}
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);
}
}
}
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