MmsCore.Excel
0.4.7
dotnet add package MmsCore.Excel --version 0.4.7
NuGet\Install-Package MmsCore.Excel -Version 0.4.7
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="MmsCore.Excel" Version="0.4.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="MmsCore.Excel" Version="0.4.7" />
<PackageReference Include="MmsCore.Excel" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add MmsCore.Excel --version 0.4.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: MmsCore.Excel, 0.4.7"
#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.
#:package MmsCore.Excel@0.4.7
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=MmsCore.Excel&version=0.4.7
#tool nuget:?package=MmsCore.Excel&version=0.4.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
This Project is not yet stable. Breaking changes may occur at any time.
MmsCore.Excel
MmsCore.Excelは、Excelファイルを読み書きするための効率的な機能を提供します。主なクラスには、ExcelReader、ExcelWriter、ExcelAccessorFactory、ExcelWorksheetReader、ExcelWorksheetWriterがあります。これらのクラスにより、Excelファイルを簡単に操作することができます。
🚀 Getting Started
IExcelReader と IExcelWorksheetReader
各セルの値を文字列として取得する場合のコード例を以下に示します。
// Excelファイルへのパスを設定します
const string xlsxFilePathToOpen = "UnitTest.xlsx";
// 一時的にスレッドのカルチャを日本語に設定します
using var temporaryThreadCulture = new TemporaryThreadCulture(new CultureInfo("ja-jp"));
// ExcelAccessorFactoryを利用してIExcelReaderのインスタンスを生成します
IExcelAccessorFactory factory = new ExcelAccessorFactory();
var reader = factory.CreateReader(xlsxFilePathToOpen);
// 指定したワークシートのリーダを取得します。存在しない場合はnullを返します
var worksheetReader = reader.GetWorksheetReaderOrNull("Sheet1");
// セル "C1"~"C4" の値を文字列として取得します
var c1 = worksheetReader?.GetStringOrNull("C1");
var c2 = worksheetReader?.GetStringOrNull("C2");
var c3 = worksheetReader?.GetStringOrNull("C3");
var c4 = worksheetReader?.GetStringOrNull("C4");
// worksheetReaderがnullでないこと、及び取得した各値が期待通りであることを検証します
Assert.NotNull(worksheetReader);
Assert.Equal("ABC", c1);
Assert.Equal("123", c2);
Assert.Equal("123.45", c3);
Assert.Equal("2022/12/31 0:00:00", c4);
各セルの値を特定の型として取得する場合のコード例を示します。
// Excelファイルへのパスを指定します
const string xlsxFilePathToOpen = "UnitTest.xlsx";
// 一時的にスレッドのカルチャを日本語に設定します
using var temporaryThreadCulture = new TemporaryThreadCulture(new CultureInfo("ja-jp"));
// ExcelAccessorFactoryを利用してIExcelReaderのインスタンスを生成します
IExcelAccessorFactory factory = new ExcelAccessorFactory();
var reader = factory.CreateReader(xlsxFilePathToOpen);
// 指定したワークシートのリーダを取得します。存在しない場合はnullを返します
var worksheetReader = reader.GetWorksheetReaderOrNull("Sheet1");
// カラム"C1"の値を文字列として取得します
var c1 = worksheetReader?.GetStringOrNull("C1");
// カラム"C2"の値をintとして取得します
var c2 = worksheetReader?.GetValueOrNull<int>("C2");
// カラム"C3"の値をdecimalとして取得します
var c3 = worksheetReader?.GetValueOrNull<decimal>("C3");
// カラム"C4"の値をDateTimeとして取得します
var c4 = worksheetReader?.GetValueOrNull<DateTime>("C4");
// worksheetReaderがnullでないこと、及び取得した各値が期待通りであることを検証します
Assert.NotNull(worksheetReader);
Assert.Equal("ABC", c1);
Assert.Equal(123, c2);
Assert.Equal(123.45m, c3);
Assert.Equal(DateTime.Parse("2022/12/31 0:00:00"), c4);
IExcelWriter と IExcelWorksheetWriter
IExcelWriter と IExcelWorksheetWriter の使用例を以下に示します。
// Excelファイルへのパスを設定します
const string xlsxFilePathToOpen = "UnitTest.xlsx";
// ExcelAccessorFactoryを利用してIExcelWriterのインスタンスを生成します
IExcelAccessorFactory factory = new ExcelAccessorFactory();
var writer = factory.CreateWriter(xlsxFilePathToOpen);
// ワークシートを用いて `IExcelWorksheetWriter` のインスタンスを生成します
var worksheetWriter = writer.GetWorksheetWriterOrNull("Sheet2");
// セルに値を設定します
var cellAddress = "A1";
var cellValue = "Hello, World!";
worksheetWriter?.SetCellValue(cellAddress, cellValue);
// 型付きのセル値も設定できます
var cellAddressInt = "B1";
var cellValueInt = 123;
worksheetWriter?.SetCellValue(cellAddressInt, cellValueInt);
var cellAddressDecimal = "C1";
var cellValueDecimal = 123.45m;
worksheetWriter?.SetCellValue(cellAddressDecimal, cellValueDecimal);
var cellAddressDateTime = "D1";
var cellValueDateTime = DateTime.Now;
worksheetWriter?.SetCellValue(cellAddressDateTime, cellValueDateTime);
// オフセットを指定してセルに値を設定します
var baseCellAddress = "A1";
var rowOffset = 1;
var columnOffset = 1;
worksheetWriter?.SetCellValue(baseCellAddress, rowOffset, columnOffset, "Offset Value");
// 行データを配列として設定します
worksheetWriter?.SetRowsDataArray(
"A2",
new[]
{
new { Name = "Alice", Age = 20, Birthday = new DateTime(2000, 1, 1) },
new { Name = "Bob", Age = 30, Birthday = new DateTime(1990, 1, 1) },
},
(item, _) => item.Name,
(item, _) => item.Age,
(item, _) => item.Birthday);
// 書き込み結果のファイルを準備します
FileInfo fileInfo = new("UnitTest-Result.xlsx");
if (fileInfo.Exists)
{
fileInfo.Delete();
}
// 書き込み結果をファイルとして保存します
using var stream = File.Open(fileInfo.FullName, FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite);
writer.SaveTo(stream);
🙏 Acknowledgments
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. 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. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.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.
-
.NETStandard 2.0
- ClosedXML (>= 0.105.0)
- MmsCore.Extensions (>= 0.4.6)
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.4.7 | 151 | 5/15/2026 |
| 0.4.6 | 228 | 4/22/2026 |
| 0.4.5 | 138 | 4/17/2026 |
| 0.4.4 | 338 | 3/14/2026 |
| 0.4.3 | 287 | 2/13/2026 |
| 0.4.2 | 171 | 1/17/2026 |
| 0.4.1 | 115 | 1/16/2026 |
| 0.4.0 | 189 | 1/1/2026 |
| 0.3.1 | 1,002 | 5/16/2025 |
| 0.3.0 | 1,051 | 1/13/2025 |
| 0.2.0 | 554 | 10/15/2024 |
| 0.1.5 | 722 | 7/19/2024 |
| 0.1.4 | 2,965 | 5/4/2024 |
| 0.1.3 | 252 | 3/13/2024 |
| 0.1.2 | 324 | 2/29/2024 |
| 0.1.1 | 601 | 2/19/2024 |
| 0.1.0 | 243 | 2/12/2024 |