Reading and writing XLSX (OOXML) is handled by unvell.ReoGrid.IO.Excel.
It depends on no external packages (neither the Open XML SDK nor EPPlus is used).
Everything is bundled with the One packages.
Reading and writing
using unvell.ReoGrid.Core;
using unvell.ReoGrid.IO.Excel;
Workbook loaded = XlsxReader.Read("book.xlsx");
XlsxWriter.Write(wb, "out.xlsx");
// ストリームからも読める
using var stream = File.OpenRead("book.xlsx");
Workbook fromStream = XlsxReader.Read(stream);
XlsxWriter.Write has a stream overload as well.
Streaming reads
Reading is streamed through XmlReader directly into the sparse store.
Memory usage is proportional to the number of cells that actually exist
(not the sheet’s declared dimensions).
Lazy loading for huge files
// 巨大ファイルはシート単位の遅延ロードで開く
using var virtualBook = XlsxReader.OpenVirtual("large.xlsx", SheetLoadMode.OnDemand);
| Mode | Behavior |
|---|---|
OnDemand | Builds each sheet the first time it is displayed |
Background | Builds the active sheet first, then prefetches the rest in the background |
VirtualWorkbook is IDisposable. It holds on to the underlying stream,
so dispose it when you are done.
How formulas are handled
Formulas are not re-evaluated on load. The cached values saved by Excel are used as-is.
var wb = XlsxReader.Read("book.xlsx");
// Excel のキャッシュ値をそのまま読むため、ロード時に再評価はしない。
// 自前で計算し直したい場合だけ明示的に呼ぶ。
foreach (var sheet in wb.Worksheets)
sheet.Recalculate();
There is a reason for this design: even for files containing functions that V5 does not
implement, the values Excel calculated are displayed as-is. Re-evaluating them would
turn them into #NAME?.
What is supported
| Feature | Read | Write |
|---|---|---|
| Values (numbers, strings, booleans, dates, errors) | Yes | Yes |
| Shared strings, inline strings, rich strings | Yes | Yes |
| Styles (font, color, alignment, wrapping) | Yes | Yes |
| Number formats | Yes | Yes |
| Borders | Yes | Yes |
| Merged cells | Yes | Yes |
| Row heights, column widths, hidden state | Yes | Yes |
| 1900 / 1904 date systems | Yes | Yes |
Conditional formatting (<conditionalFormatting> / <dxfs>) | Yes | Yes |
Defined names (<definedNames>) | Yes | Yes |
| Outlines (grouping) | Yes | Yes |
| Images (drawing) | Yes | Yes |
Page setup (<pageSetup>) | Yes | Yes |
| Formulas | Yes (cached values preserved) | Yes |
Not supported
| Feature | Notes |
|---|---|
Auto filter (<autoFilter>) | Row visibility is preserved, but the filter settings are lost |
| Shared formula expansion | |
| Cell comments | V5 has no comment feature itself |
| Charts and shapes | Same as above (images are supported) |
| Cell types | XLSX has no corresponding concept, so they become plain cells |
Built-in names (such as _xlnm.Print_Area) | Print areas are handled via PrintSettings |
| Data bar negative colors, zero axis, and borders | Requires the OOXML x14 extensions |
| View state such as freeze panes and zoom | The view is separate from the model and is not persisted |
cellStyleXfs (xfId) style inheritance | Not expanded on read |
What to read next
- PDF Export
- XLSX Compatibility Matrix