Sylvan.Data.Ods 0.1.0-b0001

Prefix Reserved
This is a prerelease version of Sylvan.Data.Ods.
The owner has unlisted this package. This could mean that the package is deprecated, has security vulnerabilities or shouldn't be used anymore.
dotnet add package Sylvan.Data.Ods --version 0.1.0-b0001
                    
NuGet\Install-Package Sylvan.Data.Ods -Version 0.1.0-b0001
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Sylvan.Data.Ods" Version="0.1.0-b0001" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Sylvan.Data.Ods" Version="0.1.0-b0001" />
                    
Directory.Packages.props
<PackageReference Include="Sylvan.Data.Ods" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Sylvan.Data.Ods --version 0.1.0-b0001
                    
#r "nuget: Sylvan.Data.Ods, 0.1.0-b0001"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Sylvan.Data.Ods@0.1.0-b0001
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Sylvan.Data.Ods&version=0.1.0-b0001&prerelease
                    
Install as a Cake Addin
#tool nuget:?package=Sylvan.Data.Ods&version=0.1.0-b0001&prerelease
                    
Install as a Cake Tool

Sylvan.Data.Ods

A cross-platform .NET library for reading OpenDocument spreadsheet data files.

OdsDataReader provides readonly, row by row, forward-only access to the data. It provides a familiar API via DbDataReader, which is ideal for accessing rectangular, tabular data sets.

The library is a purely managed implementation with no external dependencies.

If you encounter any issues while using this library, please report an issue in the github repository. Be aware that I will be unlikely to investigate any issue unless an example file can be provided reproducing the issue.

Installing

Sylvan.Data.Ods Nuget Package

Install-Package Sylvan.Data.Ods

OdsDataReader

OdsDataReader derives from DbDataReader, so it exposes an API that should be familiar for anyone who has worked with ADO.NET before. The field accessors allow reading data in an efficient, strongly-typed manner: GetString, GetInt32, GetDateTime, GetBoolean, etc.

The GetOdsDataType method allows inspecting the native Ods data type of a cell, which may vary from row to row. FieldCount, returns the number of columns in the header row, and doesn't change while processing each row in a sheet. RowFieldCount returns the number of fields in the current row, which might vary from row to row, and can be used to access cells in a "jagged", non-rectangular file.

Reading Data Manually

The OdsDataReader provides a forward only, row by row access to the data in a worksheet. It allows iterating over sheets using the NextResult() method, and iterating over rows using the Read() method. Fields are accessed using standard accessors, most commonly GetString(). GetString() is designed to not throw an exception, except in the case that a cell contains a formula error.

using Sylvan.Data.Ods;

// OdsDataReader derives from System.Data.DbDataReader
using OdsDataReader edr = OdsDataReader.Create("data.ods");

do 
{
	var sheetName = edr.WorksheetName;
	// enumerate rows in current sheet.
	while(edr.Read())
	{
		// iterate cells in row.
		// can use edr.RowFieldCount when sheet contains jagged, non-rectangular data
		for(int i = 0; i < edr.FieldCount; i++)
		{
			var value = edr.GetString(i);
		}
		// Can use other strongly-typed accessors
		// bool flag = edr.GetBoolean(0);
		// DateTime date = edr.GetDateTime(1);
		// decimal amt = edr.GetDecimal(2);
	}
	// iterates sheets
} while(edr.NextResult());

Bind Ods data to objects using Sylvan.Data

The Sylvan.Data library (a separate nuget package) includes a general-purpose data binder that can bind a DbDataReader to objects. This can be used to easily read an Ods file as a series of strongly typed objects.

using Sylvan.Data;
using Sylvan.Data.Ods;

using var edr = OdsDataReader.Create("data.ods");
foreach (MyRecord item in edr.GetRecords<MyRecord>())
{
    Console.WriteLine($"{item.Name} {item.Quantity}");
}

class MyRecord
{
    public int Id { get; set; }
    public string Name { get; set; }
    public int? Quantity { get; set; }
    public DateTime Date { get; set; }
}

Converting Ods data to CSV(s)

The Sylvan.Data.Csv library can be used to convert Ods worksheet data to CSV.

using Sylvan.Data.Ods;
using Sylvan.Data.Csv;

using var edr = OdsDataReader.Create("data.ods");

do 
{
	var sheetName = edr.WorksheetName;
	using CsvDataWriter cdw = CsvDataWriter.Create("data-" + sheetName + ".csv")
	cdw.Write(edr);
} while(edr.NextResult());
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  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 Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 is compatible. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
  • .NETStandard 2.0

    • No dependencies.
  • .NETStandard 2.1

    • No dependencies.
  • net6.0

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated