OfficeIMO.Word 0.1.4

Prefix Reserved
There is a newer version of this package available.
See the version list below for details.
dotnet add package OfficeIMO.Word --version 0.1.4                
NuGet\Install-Package OfficeIMO.Word -Version 0.1.4                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="OfficeIMO.Word" Version="0.1.4" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add OfficeIMO.Word --version 0.1.4                
#r "nuget: OfficeIMO.Word, 0.1.4"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install OfficeIMO.Word as a Cake Addin
#addin nuget:?package=OfficeIMO.Word&version=0.1.4

// Install OfficeIMO.Word as a Cake Tool
#tool nuget:?package=OfficeIMO.Word&version=0.1.4                

This is a small project (under development) that allows to create Microsoft Word documents (.docx) using .NET. Underneath it uses OpenXML SDK but heavily simplifies it. It was created because working with OpenXML is way too hard for me, and time consuming. I originally created it for using within PowerShell module called PSWriteOffice, but thought it may be useful for others to use in the .NET community.

Examples

Basic Document with few document properties and paragraph

This short example show how to create Word Document with just one paragraph with Text and few document properties.

string filePath = @"C:\Support\GitHub\PSWriteOffice\Examples\Documents\BasicDocument.docx";

using (WordDocument document = WordDocument.Create(filePath)) {
    document.Title = "This is my title";
    document.Creator = "Przemysław Kłys";
    document.Keywords = "word, docx, test";

    var paragraph = document.AddParagraph("Basic paragraph");
    paragraph.ParagraphAlignment = JustificationValues.Center;
    paragraph.Color = SixLabors.ImageSharp.Color.Red.ToHexColor();

    document.Save(true);
}

Basic Document with Headers/Footers (first, odd, even)

This short example shows how to add headers and footers to Word Document.

using (WordDocument document = WordDocument.Create(filePath)) {
    document.Sections[0].PageOrientation = PageOrientationValues.Landscape;
    document.AddParagraph("Test Section0");
    document.AddHeadersAndFooters();
    document.DifferentFirstPage = true;
    document.DifferentOddAndEvenPages = true;

    document.Sections[0].Header.First.AddParagraph().SetText("Test Section 0 - First Header");
    document.Sections[0].Header.Default.AddParagraph().SetText("Test Section 0 - Header");
    document.Sections[0].Header.Even.AddParagraph().SetText("Test Section 0 - Even");

    document.AddPageBreak();
    document.AddPageBreak();
    document.AddPageBreak();
    document.AddPageBreak();

    var section1 = document.AddSection();
    section1.PageOrientation = PageOrientationValues.Portrait;
    section1.AddParagraph("Test Section1");
    section1.AddHeadersAndFooters();
    section1.Header.Default.AddParagraph().SetText("Test Section 1 - Header");
    section1.DifferentFirstPage = true;
    section1.Header.First.AddParagraph().SetText("Test Section 1 - First Header");

    document.AddPageBreak();
    document.AddPageBreak();
    document.AddPageBreak();
    document.AddPageBreak();

    var section2 = document.AddSection();
    section2.AddParagraph("Test Section2");
    section2.PageOrientation = PageOrientationValues.Landscape;
    section2.AddHeadersAndFooters();
    section2.Header.Default.AddParagraph().SetText("Test Section 2 - Header");

    document.AddParagraph("Test Section2 - Paragraph 1");

    var section3 = document.AddSection();
    section3.AddParagraph("Test Section3");
    section3.AddHeadersAndFooters();
    section3.Header.Default.AddParagraph().SetText("Test Section 3 - Header");

    Console.WriteLine("Section 0 - Text 0: " + document.Sections[0].Paragraphs[0].Text);
    Console.WriteLine("Section 1 - Text 0: " + document.Sections[1].Paragraphs[0].Text);
    Console.WriteLine("Section 2 - Text 0: " + document.Sections[2].Paragraphs[0].Text);
    Console.WriteLine("Section 2 - Text 1: " + document.Sections[2].Paragraphs[1].Text);
    Console.WriteLine("Section 3 - Text 0: " + document.Sections[3].Paragraphs[0].Text);

    Console.WriteLine("Section 0 - Text 0: " + document.Sections[0].Header.Default.Paragraphs[0].Text);
    Console.WriteLine("Section 1 - Text 0: " + document.Sections[1].Header.Default.Paragraphs[0].Text);
    Console.WriteLine("Section 2 - Text 0: " + document.Sections[2].Header.Default.Paragraphs[0].Text);
    Console.WriteLine("Section 3 - Text 0: " + document.Sections[3].Header.Default.Paragraphs[0].Text);
    document.Save(true);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 is compatible.  net5.0-windows was computed.  net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 is compatible.  net48 is compatible.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
0.20.0 3,005 9/27/2024
0.19.0 1,567 9/24/2024
0.18.0 320 9/22/2024
0.17.0 6,613 6/21/2024
0.16.0 1,981 6/17/2024
0.15.0 6,008 5/13/2024
0.14.0 7,294 4/4/2024
0.13.0 6,704 2/2/2024
0.12.0 3,319 12/31/2023
0.11.0 2,007 11/27/2023
0.10.0 6,913 10/24/2023
0.9.0 7,294 8/15/2023
0.8.0 4,248 7/30/2023
0.7.0 3,613 7/16/2023
0.6.0 718 7/3/2023
0.5.0 1,159 6/5/2023
0.4.9 10,689 3/19/2023
0.4.8 9,301 2/8/2023
0.4.7 3,224 1/14/2023
0.4.6 2,926 1/11/2023
0.4.5 785 1/9/2023
0.4.4 751 1/9/2023
0.4.3 755 1/9/2023
0.4.2 3,801 11/25/2022
0.4.1 804 11/20/2022
0.4.0 3,958 11/13/2022
0.3.1 1,974 10/18/2022
0.3.0 1,191 10/11/2022
0.2.1 1,124 7/31/2022
0.2.0 792 7/31/2022
0.1.7 935 6/12/2022
0.1.6 899 6/11/2022
0.1.5 832 6/4/2022
0.1.4 1,056 4/3/2022
0.1.3 887 4/3/2022