QuickWord.OpenXml 1.0.3

dotnet add package QuickWord.OpenXml --version 1.0.3
NuGet\Install-Package QuickWord.OpenXml -Version 1.0.3
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="QuickWord.OpenXml" Version="1.0.3" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add QuickWord.OpenXml --version 1.0.3
#r "nuget: QuickWord.OpenXml, 1.0.3"
#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 QuickWord.OpenXml as a Cake Addin
#addin nuget:?package=QuickWord.OpenXml&version=1.0.3

// Install QuickWord.OpenXml as a Cake Tool
#tool nuget:?package=QuickWord.OpenXml&version=1.0.3

QuickWord for DocumentFormat.OpenXml

A set of extension methods for DocumentFormat.OpenXml which simplifies creating and modifying Word documents (such as .docx). You can use these methods with your existing DocumentFormat.OpenXml code without having to change anything.

Getting Started

Example document creation with 1 formatted paragraph:

string fileName = "TEST.docx";

using (var document = WordprocessingDocument.Create(fileName, WordprocessingDocumentType.Document))
{
	Body body = document.CreateBody()
	  .PageWidth(21, MeasuringUnits.Centimeters) // A4 width
	  .PageHeight(29.7, MeasuringUnits.Centimeters); // A4 height

	body.AppendChild(new Paragraph(
		new Run().Text("This is a single, centered paragraph.")
		  .FontSize(16)
		  .FontColor("Red") // #FF0000 will also work
		  .FontFace("Times New Roman"))
		.Justification(JustificationValues.Center));

	document.Save();
}

Highlighted Features

  • Super quick and easy Builder-like pattern:
var run = new Run().Text("This is a simple Run.")
  .FontSize(24)
  .FontColor("Red")
  .Bold()
  .Italic();

  • The ability to create Paragraphs with multiple Runs and multiple formattings:
Run[] runs = new[]
{
	new Run().Text("This is a").FontSize(16),
	new Run().Text(" single paragraph ").FontFace("Comic Sans MS"),
	new Run().Text("with 3 Runs.").HighlightColor(HighlightColorValues.Cyan)
};

body.AppendChild(new Paragraph(runs))

  • The ability to create tables quickly:
body.AppendChild(QTable.Create(new[]
{
	new[] { "1", "John", "Doe" },
	new[] { "2", "Jane", "Doe" },
	new[] { "3", "John", "Smith" },
	new[] { "4", "Jane", "Smith" }
}));

  • The ability quickly merge cells:
// Merge cells [0,0] and [1,0] (vertically)
table.Rows(0)?.Cells(0)?.VerticalMerge(MergedCellValues.Restart);
table.Rows(1)?.Cells(0)?.VerticalMerge(MergedCellValues.Continue);

// Merge cells [2,0] and [3,0] (vertically)
table.Rows(2)?.Cells(0)?.VerticalMerge(MergedCellValues.Restart);
table.Rows(3)?.Cells(0)?.VerticalMerge(MergedCellValues.Continue);

  • The ability to quickly create formatted rows and cells:
table1.AppendChild(QTableRow.Create(
	new[] { "ID", "First Name", "Last Name" },
	rowFormatting: new TableRowFormatting { IsHeader = true },
	runFormatting: new RunFormatting { Bold = true }));
  • The ability to easily customize existing table cells:
foreach (TableCell? cell in table2.GetColumnOfCells(3).Skip(1)) // 4th column of cells, skip header cell
{
	if (cell?.Paragraphs(0)?.GetText() == "Yes")
		cell?.FillColor("LightGreen");
	else
		cell?.FillColor("LightPink");
}

  • The ability to create inlined images:
body.AppendChild(new Paragraph(
	new Run(QDrawing.FromImage(body, "Icon.png", ImagePartType.Png, 32, 32)),
	new Run().Text(" This image is inlined with the text.").VerticalPosition(8)
).Justification(JustificationValues.Center));

  • The ability to create anchored images:
body.AppendChild(new Paragraph(
	new Run(QDrawing.FromImage(body, "Icon.png", ImagePartType.Png, 128, 128)
		.ToAnchoredDrawing()
		.AbsoluteVerticalPosition(0, ImageMeasuringUnits.Pixels, DW.VerticalRelativePositionValues.Paragraph)
		.SquareWrapping(0, 0, 0.5, 0, ImageMeasuringUnits.Centimeters)),

	new Run().Text("This\nimage\nis\naligned\nbefore\nthe text.\n")
));

With images you can also:

  • Set the transparency
  • Set the rotation
  • Set cropping
  • Set a border
  • Set text wrapping
  • Set the position
  • many more...

  • You can also use additional Paragraph inherited objects, such as:
    • EmptyLine
    • PageBreak
    • HorizontalLine
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  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 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  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
1.0.3 147 10/3/2023
1.0.2 156 10/3/2023
1.0.1 143 10/2/2023
1.0.0 160 10/1/2023