CompuMaster.Excel.MicrosoftExcel
2026.12.1.2
dotnet add package CompuMaster.Excel.MicrosoftExcel --version 2026.12.1.2
NuGet\Install-Package CompuMaster.Excel.MicrosoftExcel -Version 2026.12.1.2
<PackageReference Include="CompuMaster.Excel.MicrosoftExcel" Version="2026.12.1.2" />
<PackageVersion Include="CompuMaster.Excel.MicrosoftExcel" Version="2026.12.1.2" />
<PackageReference Include="CompuMaster.Excel.MicrosoftExcel" />
paket add CompuMaster.Excel.MicrosoftExcel --version 2026.12.1.2
#r "nuget: CompuMaster.Excel.MicrosoftExcel, 2026.12.1.2"
#:package CompuMaster.Excel.MicrosoftExcel@2026.12.1.2
#addin nuget:?package=CompuMaster.Excel.MicrosoftExcel&version=2026.12.1.2
#tool nuget:?package=CompuMaster.Excel.MicrosoftExcel&version=2026.12.1.2
CompuMaster.Excel.MicrosoftExcel
A library to access and edit Excel files with common interface CompuMaster.Excel.ExcelOps for several Excel engines
Use Microsoft.Office.Interop.Excel v15 (MS Office 2013) or higher, for solutions targetting .NET Framework 4.8 or .NET 6 or higher
Quick & dirty engine comparison / why you shouldn't use MS Excel for all situations
For a full engine overview and comparison chart, please see https://github.com/CompuMasterGmbH/CompuMaster.Excel/blob/main/README.md
Licensing
- Please see license file in project directory
- Pay attention to required licensing of the 3rd party components (commercial vs. community licensing, user licensing, etc.)
Examples
PDF Export and Printing
The PDF and print methods are available through ExcelDataOperationsBase. Microsoft Excel uses the workbook's existing page setup, including the print areas. The selected workbook or named sheet can be exported without activating the sheet.
workbook.ExportWorkbookToPdf("workbook.pdf");
workbook.ExportSheetToPdf("Summary", "summary.pdf", fromPageIndex: 0, toPageIndex: 0);
workbook.PrintWorkbook();
workbook.PrintSheet("Summary", printerName: workbook.Workbook.Application.ActivePrinter, copies: 2);
The page arguments are zero-based. Omit both arguments to include all printed pages. Print methods use Excel's active printer unless you supply its full printer name in Excel's format. For example, read the exact name of a configured printer from Excel's active printer property after selecting it. The print methods submit a job to the driver. Specify a print-to-file path when the selected driver supports it. Use the dedicated PDF export methods when the application needs a PDF independently of the printer driver.
Export Charts
The encoded API uses Excel's installed native graphics filters. It exports PNG by default and also accepts JPEG and GIF. The output includes the image bytes, MIME type, file extension and chart name. Chart sheets can be exported or embedded in HTML. Worksheet HTML export is unavailable in this engine.
var image = workbook.ExportChartSheet("Sales Chart", new ChartExportOptions
{
Backend = ChartRenderBackend.NativeExcel,
Format = "jpeg"
});
File.WriteAllBytes("sales." + image.FileExtension, image.ToArray());
On Windows, ExportChartSheetImage renders a chart sheet through Excel's native PNG filter. ExportChartImage renders every chart embedded on a worksheet in Excel's chart object order. The returned images are independent of the workbook and the export's temporary files. Dispose them after use.
using var chart = workbook.ExportChartSheetImage("Sales Chart");
chart.Save("sales.png", System.Drawing.Imaging.ImageFormat.Png);
Excel diagnostic logs
MsExcelDataOperations.DiagnosticLogFiles and MsExcelApplicationWrapper.DiagnosticLogFiles return read-only snapshots of existing, positively associated Office diagnostic logs. Reading these properties does not start Excel or create logs. Surviving paths remain available after closing the application.
PreserveDiagnosticLogFiles defaults to false and is shared by workbooks using the same Excel process. After the existing shutdown sequence confirms that the exact process has exited, a successful quit with exit code zero removes its associated logs. An error or forced exit retains them and trims only trailing NUL padding, preserving Unicode terminal code units. Set PreserveDiagnosticLogFiles = true to leave every log byte unchanged, including padding.
BOMs and recognizable Office headers identify the text encoding. Ambiguous BOM-less logs may retain up to three trailing padding bytes to protect UTF-16/UTF-32 terminal code units.
Ownership requires the process ID and start time, valid log timestamps, and the Primary/Additional session GUID. A query-only Windows Restart Manager session can identify exclusively locked Primary logs. Unknown formats, uncertain ownership, inaccessible or replaced files, and reparse points are skipped. Housekeeping never changes the existing Quit/COM-release/wait/kill sequence or Office logging settings. Housekeeping makes at most three attempts, waiting 350 ms between attempts. A host crash cannot run in-process housekeeping.
Quick-Start: Create a workbook and put some values and formulas, then output the result to console
using CompuMaster.Excel.ExcelOps;
string FirstSheetName;
TextTable formulasOrValues;
TextTable values;
//Create a workbook and put some values and formulas
workbook = new MsExcelDataOperations(null, ExcelDataOperationsBase.OpenMode.CreateFile, new ExcelDataOperationsOptions());
FirstSheetName = workbook.SheetNames()[0];
workbook.WriteCellValue<int>(FirstSheetName, 0, 0, 123);
workbook.WriteCellValue<double>(new ExcelCell(FirstSheetName, "B1", ExcelCell.ValueTypes.All), 456.123);
workbook.WriteCellFormula(FirstSheetName, 0, 2, @"SUM(A1:B1)", true);
//Output table with formulas or alternatively with formatted cell value
formulasOrValues = workbook.SheetContentMatrix(FirstSheetName, ExcelDataOperationsBase.MatrixContent.FormulaOrFormattedText);
System.Console.WriteLine(formulasOrValues.ToUIExcelTable());
//Output table with calculated or static values
values = workbook.SheetContentMatrix(FirstSheetName, ExcelDataOperationsBase.MatrixContent.StaticOrCalculatedValues);
System.Console.WriteLine(values.ToUIExcelTable());
leads to following output
# |A |B |C
--+---+-------+-----------
1 |123|456,123|=SUM(A1:B1)
# |A |B |C
--+---+-------+-------
1 |123|456,123|579,123
</details>
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | 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. 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 Framework | net48 is compatible. net481 was computed. |
-
.NETFramework 4.8
- CompuMaster.ComInterop (>= 1.0.2026.1112)
- CompuMaster.Excel.ExcelOps (>= 2026.12.1.2)
-
net6.0
- CompuMaster.ComInterop (>= 1.0.2026.1112)
- CompuMaster.Excel.ExcelOps (>= 2026.12.1.2)
NuGet packages (1)
Showing the top 1 NuGet packages that depend on CompuMaster.Excel.MicrosoftExcel:
| Package | Downloads |
|---|---|
|
CompuMaster.Excel.Tools.MicrosoftAndEpplus
Package Description |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2026.12.1.2 | 11 | 12/1/2026 |
| 2026.12.1.1 | 58 | 12/1/2026 |
| 2026.12.1 | 53 | 12/1/2026 |
| 2026.11.30 | 96 | 11/30/2026 |
| 2026.11.29.1 | 107 | 11/29/2026 |
| 2026.11.29 | 106 | 11/29/2026 |
| 2026.11.27 | 105 | 11/27/2026 |
| 2026.11.26 | 108 | 11/26/2026 |
| 2026.11.24 | 122 | 11/24/2026 |
| 2026.11.12 | 141 | 11/12/2026 |
| 2026.10.9 | 212 | 10/9/2026 |
| 2026.10.8.1 | 141 | 10/8/2026 |
| 2026.10.8 | 134 | 10/8/2026 |
| 2026.10.7.1 | 140 | 10/7/2026 |
| 2026.10.7 | 134 | 10/7/2026 |
| 2026.9.29 | 147 | 9/29/2026 |
| 2026.9.28 | 144 | 9/28/2026 |
| 2026.8.31 | 155 | 8/31/2026 |
| 2026.7.30.1 | 176 | 7/30/2026 |
| 2026.7.30 | 172 | 7/30/2026 |