You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The [.NET Word Library](https://www.syncfusion.com/document-sdk/net-word-library) (DocIO) enables you to create, read, and edit Word documents programmatically without Microsoft Word or interop dependencies. Using this library, you can **split a Word document by sections** using C#.
4
+
5
+
## Steps to split Word document by sections programmatically
6
+
7
+
Step 1: Create a new .NET Core console application project.
8
+
9
+
Step 2: Install the [Syncfusion.DocIO.Net.Core](https://www.nuget.org/packages/Syncfusion.DocIO.Net.Core) NuGet package as a reference to your project from [NuGet.org](https://www.nuget.org/).
10
+
11
+
Step 3: Include the following namespaces in the Program.cs file.
12
+
13
+
```csharp
14
+
usingSyncfusion.DocIO;
15
+
usingSyncfusion.DocIO.DLS;
16
+
usingSystem.IO;
17
+
```
18
+
19
+
Step 4: Add the following code snippet in Program.cs file to split Word document by sections.
20
+
21
+
```csharp
22
+
using (FileStreaminputStream=newFileStream(Path.GetFullPath(@"Data/Template.docx"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
23
+
{
24
+
//Load the template document as stream
25
+
using (WordDocumentdocument=newWordDocument(inputStream, FormatType.Docx))
using (FileStreamoutputStream=newFileStream(Path.GetFullPath(@"Output/Section") +i+".docx", FileMode.OpenOrCreate, FileAccess.ReadWrite))
37
+
{
38
+
newDocument.Save(outputStream, FormatType.Docx);
39
+
}
40
+
}
41
+
}
42
+
}
43
+
}
44
+
```
45
+
46
+
More information about splitting a Word document can be found in this [documentation](https://help.syncfusion.com/document-processing/word/word-library/net/word-document/split-word-documents) section.
0 commit comments