Полный код
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/
AddAndDeleteParagraphs();
}
/// <summary>
/// ElementCollection: Adds 20 paragraphs into document and delete 10 of them.
/// </summary>
/// <remarks>
/// Details: https://sautinsoft.com/products/document/help/net/developer-guide/elementcollection-add-delete.php
/// </remarks>
static void AddAndDeleteParagraphs()
{
DocumentCore dc = new DocumentCore();
Section section = new Section(dc);
dc.Sections.Add(section);
for (int i = 0; i < 20; i++)
{
Paragraph par = new Paragraph(dc,"Text "+ i.ToString());
section.Blocks.Add(par);
}
dc.Save("ResultFull.docx");
for (int i = 0; i < section.Blocks.Count; )
{
section.Blocks.RemoveAt(i);
i++;
}
dc.Save("ResultShort.docx");
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("ResultFull.docx") { UseShellExecute = true });
System.Diagnostics.Process.Start(new System.Diagnostics.ProcessStartInfo("ResultShort.docx") { UseShellExecute = true });
}
}
}
Imports System
Imports System.IO
Imports SautinSoft.Document
Module Sample
Sub Main()
AddAndDeleteParagraphs()
End Sub
''' Get your free 100-day key here:
''' https://sautinsoft.com/start-for-free/
''' <summary>
''' ElementCollection: Adds 20 paragraphs into document and delete 10 of them.
''' </summary>
''' <remarks>
''' Details: https://sautinsoft.com/products/document/help/net/developer-guide/elementcollection-add-delete.php
''' </remarks>
Sub AddAndDeleteParagraphs()
Dim dc As New DocumentCore()
Dim section As New Section(dc)
dc.Sections.Add(section)
For i As Integer = 0 To 19
Dim par As New Paragraph(dc, "Text " & i.ToString())
section.Blocks.Add(par)
Next i
dc.Save("ResultFull.docx")
Dim j As Integer = 0
Do While j < section.Blocks.Count
section.Blocks.RemoveAt(j)
j += 1
Loop
dc.Save("ResultShort.docx")
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo("ResultFull.docx") With {.UseShellExecute = True})
System.Diagnostics.Process.Start(New System.Diagnostics.ProcessStartInfo("ResultShort.docx") With {.UseShellExecute = True})
End Sub
End Module
Если вам нужен пример кода или у вас есть вопрос: напишите нам по адресу support@sautinsoft.ru или спросите в онлайн-чате (правый нижний угол этой страницы) или используйте форму ниже: