Table of Contents

OpenDocument Spreadsheet

OdsWriter.Write writes a workbook as an OpenDocument Spreadsheet (.ods, ODF 1.3), as LibreOffice writes Excel's workbooks: each worksheet's values and formulas, number formats, fonts, fills, borders and alignment, column widths, row heights and merged cells. LibreOffice opens the result and converts it back to .xlsx with every value and formula as it was. What ODF cannot carry is reported, never dropped in silence.

dotnet add package DocWright.Spreadsheet

Write a workbook as .ods

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

XlsxDocument workbook = XlsxDocument.Open(File.OpenRead("sales-book.xlsx"));
var diagnostics = new CollectingConversionDiagnostics();
using (FileStream output = File.Create("sales-book.ods"))
{
    OdsWriter.Write(workbook, output, new OdsWriteOptions { Diagnostics = diagnostics });
}

foreach (ConversionDiagnostic said in diagnostics.Snapshot())
{
    Console.WriteLine($"{said.Code} {said.Location}: {said.Message}");
}

Console.WriteLine($"{workbook.Sheets.Count} sheet(s) written to sales-book.ods");
DXP2002 Pivot: 'Pivot' has pivot tables; they are not written to the .ods file.
DXP2002 Sales: 'Sales' has charts; they are not written to the .ods file.
DXP2002 Sales: 'Sales' has conditional formats; they are not written to the .ods file.
DXP2002 Sales: 'Sales' has data validations; they are not written to the .ods file.
DXP2002 Sales: 'Sales' has hyperlinks; they are not written to the .ods file.
DXP2002 Sales: 'Sales' has notes; they are not written to the .ods file.
DXP2002 Sales: 'Sales' has tables (their cells are written, the table definitions are not); they are not written to the .ods file.
DXP2002 Sales: 'Sales' has frozen panes; they are not written to the .ods file.
DXP2005 Sales!E2: The formula of Sales!E2 (SUM(SalesTable[Amount])) has no OpenFormula form (a table's structured reference (SalesTable[Amount]) has no OpenFormula form here); its value is written.
2 sheet(s) written to sales-book.ods

Download the result: sales-book.ods.

What is written, and what is reported

In the .ods file
Formulas In OpenFormula, spelled as LibreOffice spells Excel's: of:=SUM([.A1:.A4]), ; between arguments, Excel's newer functions as COM.MICROSOFT.. A formula with no OpenFormula form (a table's structured reference, another workbook, a spilled range) is written as its value and reported (DXP2005).
Values Numbers, text, booleans, dates and times, percentages, errors; the 1904 date system is kept.
Number formats As ODF data styles: digits, percentages, scientific numbers, text, colours, dates and times, up to three sections. Fractions and conditions are reported and shown as General (DXP2006).
Looks Fonts, fills, borders, alignment, wrap, rotation, indent, cell protection. Dash-dot borders are written dashed (DXP2006).
Sheets Column widths, row heights, hidden rows and columns, merged cells, hidden sheets.
Not written Charts, pictures, shapes, controls, sparklines, conditional formats, validations, hyperlinks, notes, pivot tables, table definitions, protection and frozen panes, each named once for its sheet (DXP2002).
Note

Reading an .ods file is not offered.