Table of Contents

Legacy .xls workbooks

XlsReader.Open reads an Excel 97-2003 workbook (.xls, BIFF8) into the same XlsxDocument every workbook operation works on: its sheets, cells, formulas, names, number formats, fonts, fills, borders, merged cells, column widths and row heights. Saving writes .xlsx; there is no .xls writer.

dotnet add package DocWright.Spreadsheet.Xls

Open a workbook

using DocWright.Core.Diagnostics;
using DocWright.Spreadsheet;
using DocWright.Spreadsheet.Xls;

var diagnostics = new CollectingConversionDiagnostics();
XlsxDocument workbook = XlsReader.Open(File.OpenRead("legacy.xls"), new XlsxReadSettings { Diagnostics = diagnostics });
foreach (XlsxDocumentSheet sheet in workbook.Sheets)
{
    Console.WriteLine($"{sheet.Name} ({sheet.Visibility}): {sheet.Cells.Count()} cells");
}

XlsxDocumentSheet data = workbook.FindSheet("Data")!;
Console.WriteLine($"D3 = {data.GetCell("D3").Formula} -> {data.GetCell("D3").DisplayText}");
Console.WriteLine($"A15 shows {data.GetCell("A15").DisplayText}");
foreach (ConversionDiagnostic said in diagnostics.Snapshot())
{
    Console.WriteLine($"{said.Code}: {said.Message}");
}
Data (Visible): 65 cells
Other Sheet (Visible): 1 cells
Hidden (Hidden): 1 cells
D3 = B3*C3 -> 29.25
A15 shows 2025-12-09

Formulas are read from the tokens the file stores, shared and array formulas included, and the cells keep the values the file cached. What the reader leaves out is reported once for each sheet: charts, drawings, notes, hyperlinks, validations, conditional formats, pivot tables, protection and macros (DXP2002). An Excel 5.0/95 file and an encrypted .xls are refused with typed exceptions.

Save it as .xlsx

using DocWright.Spreadsheet;

using (FileStream output = File.Create("legacy.xlsx"))
{
    workbook.Save(output);
}

Download the result: legacy.xlsx.