Полный код
using System;
using System.Linq;
using SautinSoft.Document;
namespace Example
{
class Program
{
static void Main(string[] args)
{
// Get your free 100-day key here:
// https://sautinsoft.com/start-for-free/
ShowLists();
}
/// <summary>
/// Find all paragraphs in a document marked as list (ordered or unordered).
/// </summary>
/// <remarks>
/// Details: https://sautinsoft.com/products/document/help/net/developer-guide/elementcollection-linq.php
/// </remarks>
static void ShowLists()
{
string filePath = @"..\..\..\example.docx";
DocumentCore dc = DocumentCore.Load(filePath);
// Select all paragraphs marked as list using LINQ.
var selectedPars = from p in dc.GetChildElements(true, ElementType.Paragraph)
where (p as Paragraph).ListFormat.IsList
select p;
foreach (Paragraph p in selectedPars)
Console.WriteLine(p.Content.ToString().TrimEnd());
Console.ReadKey();
}
}
}
Imports System
Imports System.Linq
Imports SautinSoft.Document
Module Sample
Sub Main()
ShowLists()
End Sub
''' Get your free 100-day key here:
''' https://sautinsoft.com/start-for-free/
''' <summary>
''' Find all paragraphs in a document marked as list (ordered or unordered).
''' </summary>
''' <remarks>
''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/elementcollection-linq.php
''' </remarks>
Sub ShowLists()
Dim filePath As String = "..\..\..\example.docx"
Dim dc As DocumentCore = DocumentCore.Load(filePath)
' Select all paragraphs marked as list using LINQ.
Dim selectedPars = From p In dc.GetChildElements(True, ElementType.Paragraph)
Where (TryCast(p, Paragraph)).ListFormat.IsList
Select p
For Each p As Paragraph In selectedPars
Console.WriteLine(p.Content.ToString().TrimEnd())
Next p
Console.ReadKey()
End Sub
End Module
Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу support@sautinsoft.ru или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже: