SharpCell

Reading .xlsx files

What XlsxReader loads, what it skips, and how saved results and streams behave. It reads .xlsx files and macro-enabled .xlsm and .xltm files; macros are kept for saving and never run.

What is read

What is not read

Pattern and gradient fills, styles of whole rows and columns, charts, pivot tables, threaded comments and macros are skipped. Conditional formats in the extension list (newer data bars and icon sets) stay in the file without being read.

File Result
.xls, .xlsb, encrypted files NotSupportedException
A damaged or non-xlsx file InvalidDataException

Saved results

After Load, a cell with a formula holds the result Excel saved in the file. A file written by another program may have no saved results; those cells are empty. Workbook.Recalculate calculates every formula with SharpCell and replaces the saved results.

A formula SharpCell cannot parse, such as a link to another workbook, does not fail the load. Once calculated, it is #NAME? and listed in Workbook.Diagnostics as UnsupportedFormula.

A legacy array formula covers a fixed range. Setting the value or formula of one of its cells other than the top-left one throws InvalidOperationException; change the whole array at its top-left cell.

Streams

using Stream stream = File.OpenRead(path);
Workbook workbook = XlsxReader.Load(stream);   // the stream is left open

The stream does not have to be seekable; a stream that is not is copied into memory first.

Writing

XlsxWriter saves a workbook into the file it was read from, keeping what SharpCell does not read; see Saving .xlsx files.