Apodemus.NPOI.XWPFMapper
1.0.0
See the version list below for details.
dotnet add package Apodemus.NPOI.XWPFMapper --version 1.0.0
NuGet\Install-Package Apodemus.NPOI.XWPFMapper -Version 1.0.0
<PackageReference Include="Apodemus.NPOI.XWPFMapper" Version="1.0.0" />
paket add Apodemus.NPOI.XWPFMapper --version 1.0.0
#r "nuget: Apodemus.NPOI.XWPFMapper, 1.0.0"
// Install Apodemus.NPOI.XWPFMapper as a Cake Addin
#addin nuget:?package=Apodemus.NPOI.XWPFMapper&version=1.0.0
// Install Apodemus.NPOI.XWPFMapper as a Cake Tool
#tool nuget:?package=Apodemus.NPOI.XWPFMapper&version=1.0.0
<img src="logos/xwpfmapper-logo.png" data-canonical-src="logos/xwpfmapper-logo.png" height="23"/> NPOI.XWPFMapper
This is a library for mapping objects to Word document tables with the NPOI library.
<img src="logos/xwpfmapper-logo.png" data-canonical-src="logos/xwpfmapper-logo.png" width="200"/>
Usage
You can take a look at the
NPOI.XWPFMapper.ConsoleApp
project for a working example.
NPOI.XWPFMapper
uses the interface IXWPFMappable
and the attribute XWPFPropertyAttribute
to define which classes should be mappable and which members should be nested or just strings.
internal class ExampleClass : IXWPFMappable // Implement the IXWPFMappable interface to make a class mappable
{
// Add the XWPFPropertyattribute to make a member mappable.
[XWPFProperty("Color")]
public ExampleEnum Enum { get; set; }
[XWPFProperty("Name")]
public string Name { get; set; }
// This child class also implements IXWPFMappable and will become a nested table.
[XWPFProperty("Address")]
public ExampleChildClass Address { get; set; }
// Without the XWPFPropertyAttribute a member will be ignored by the mapping.
public string IgnoredMember { get; set; }
}
internal class ExampleChildClass : IXWPFMappable
{
[XWPFProperty("Street")]
public string Address { get; set; }
[XWPFProperty("Place")]
public string City { get; set; }
[XWPFProperty("Country")]
public string CountryCode { get; set; }
}
In addition to this, there is also the XWPFTableWrapper
, which is a class that manages an XWPFTable
. It only accepts a single Type to be mapped (excluding its members of course).
XWPFDocument document = new XWPFDocument();
ExampleClass exampleData = new ExampleClass()
{
Enum = ExampleEnum.Red,
Name = "This is a test",
IgnoredMember = "This member will be ignored",
Address = new ExampleChildClass()
{
Address = "Burgemeester Schönfeldplein",
City = "Winschoten",
CountryCode = "NL"
}
};
// XWPFTableWrapper requires a Type argument and an XWPFDocument object to work
// In addition you can optionally set the direction of the table with an enum XWPFTableAlignment (default is Row)
XWPFTableWrapper<ExampleClass> wrapper = new XWPFTableWrapper<ExampleClass>(document, XWPFTableAlignment.Column);
wrapper.Insert(exampleData);
The table alignment refers to how the individual member values are inserted and not to how new records are added to the table.
XWPFTableAlignment.Row
Color | Red |
---|---|
Name | This is a test |
Address | Van Nelleweg 1, Rotterdam |
XWPFTableAlignment.Column
Color | Name | Address |
---|---|---|
Red | This is a test | Van Nelleweg 1, Rotterdam |
XWPFTableWrapper
's XWPFTable
is public, so you can access it from XWPFTableWrapper
.
🏳️⚧️ Trans Rights are human rights!
Product | Versions 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 | netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
.NET Standard | netstandard2.1 is compatible. |
MonoAndroid | monoandroid was computed. |
MonoMac | monomac was computed. |
MonoTouch | monotouch was computed. |
Tizen | tizen60 was computed. |
Xamarin.iOS | xamarinios was computed. |
Xamarin.Mac | xamarinmac was computed. |
Xamarin.TVOS | xamarintvos was computed. |
Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.1
- Microsoft.CSharp (>= 4.7.0)
- NPOI (>= 2.5.6)
-
net6.0
- Microsoft.CSharp (>= 4.7.0)
- NPOI (>= 2.5.6)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.