Overview of NPOI
masterNPOI.SS namespace).repository·master·Indexed 27 days ago
https://github.com/nissl-lab/npoiA .NET library for reading and writing Microsoft Office files, including Excel (.xls, .xlsx) and Word (.docx). A port of the Apache POI project, NPOI supports .NET 8, .NET Standard 2.0/2.1, and .NET Framework 4.0+. It provides functionality for managing POIFS filesystem objects via the Entry interface, implementing Excel functions like INDEX, and offering utility collections such as BidirectionalDictionary. The library also includes classes for configuring VML shapes, fills, and paths.
NPOI.SS namespace).NPOI is compatible with the following runtimes:
You can create a read-only view of a dictionary using different methods depending on the type you are working with:
BidirectionalDictionary<TKey, TValue>, use the .AsReadOnly() method.IBidirectionalDictionary interface, wrap it in a new ReadOnlyBidirectionalDictionary<TKey, TValue>.// From a BidirectionalDictionary instance
var readOnlyDictionary = dictionary.AsReadOnly();
// From an IBidirectionalDictionary instance
using System.Collections.ObjectModel;
var readOnlyDictionary = new ReadOnlyBidirectionalDictionary<string, string>(dictionary);Since version 2.8.0, NPOI includes an EULA on binary releases and NuGet packages that requires a monthly maintenance fee for organizations or users who generate revenue from using the library.
For details on eligibility and FAQs, visit the Open Source Maintenance Fee website. Fees can be paid via GitHub Sponsors.
A BidirectionalDictionary (also known as a BiMap or Two-way dictionary) allows you to look up values by keys and keys by values. It is compatible with .NET Standard 2.0. You can access the reverse mapping via the .Inverse property.
using System.Collections.Generic;
var countryCapitalDictionary = new BidirectionalDictionary<string, string>()
{
["Italy"] = "Rome",
["India"] = "New Delhi",
["USA"] = "Washington, D.C.",
};
Console.WriteLine(countryCapitalDictionary["Italy"]); // "Rome"
Console.WriteLine(countryCapitalDictionary.Inverse["Rome"]); // "Italy"NPOI supports the following file formats:
.xls (Excel 2003).xlsx (Excel 2007+).docx (Word 2007+)Key features include support for Excel cell styles, data formats, and formulas.
The library provides the following interfaces to allow for abstraction and flexibility in your code. Both BidirectionalDictionary and ReadOnlyBidirectionalDictionary implement these interfaces:
IBidirectionalDictionaryIReadOnlyBidirectionalDictionaryUse the CT_Textbox class to represent VML textbox elements. You can set the id, style, and inset attributes. The ItemXml property allows you to store and retrieve the inner XML content of the textbox.
To create a CT_Textbox from an existing XML node, use the Parse method.
Use the CT_TextPath class to define text paths in VML. Key properties include:
id: The element identifier.style: The CSS-like style string.on: A ST_TrueFalse value indicating if the path is active.fitshape: Whether the text fits the shape.fitpath: Whether the text fits the path.trim: Whether to trim the text.xscale: The horizontal scaling factor.@string: The actual text content.Use CT_TextPath.Parse(node, namespaceManager) to instantiate from an XML node.
The CT_Fill class represents a VML fill definition. You can configure various attributes such as color, opacity, type, and source to define how a shape is filled.
Key properties include:
id: Unique identifier.type: The fill type (e.g., solid, gradient, tile).color / color2: Color values.opacity: Opacity level.src: Source for the fill (e.g., an image).angle: Rotation angle for gradients.Use AddNewFill() on a CT_Shape to initialize a new fill object.
CT_Handles is used to define a collection of handles (CT_H) for a shape, typically used for resizing or manipulation in UI contexts.
Use AddNewH() to add a new handle to the collection.
CT_Arc class defines a VML arc. It includes properties for the start and end angles (startAngle, endAngle) and supports various child elements like path, fill, stroke, and shadow. Note that startAngle and endAngle require setting the startAngleSpecified and endAngleSpecified flags (handled via the Specified pattern) to be included in the XML output.