SheetsPersist 1.2.0-alpha

This is a prerelease version of SheetsPersist.
There is a newer version of this package available.
See the version list below for details.
dotnet add package SheetsPersist --version 1.2.0-alpha
NuGet\Install-Package SheetsPersist -Version 1.2.0-alpha
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="SheetsPersist" Version="1.2.0-alpha" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add SheetsPersist --version 1.2.0-alpha
#r "nuget: SheetsPersist, 1.2.0-alpha"
#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.
// Install SheetsPersist as a Cake Addin
#addin nuget:?package=SheetsPersist&version=1.2.0-alpha&prerelease

// Install SheetsPersist as a Cake Tool
#tool nuget:?package=SheetsPersist&version=1.2.0-alpha&prerelease

SheetsPersist

Simple Object Persistence and Logging to Google Sheets

SheetsPersist gives you two ways to integrate .NET object instances with Google Sheets.

  1. Object Persistence (read and write object instances to/from a spreadsheet).
  2. Logging (send .NET instances to a rich log kept in a spreadsheet).

Spreadsheet Registration

First, register the spreadsheet you want to work with like this:

GoogleSheets.RegisterDocumentID("LogTest", "1YnqCNZFqfdRP_7ocmAkD0dpI-G_bFnwGH1vN-YppAZE");

The first parameter is the name of the spreadsheet as you would like to refer to it in the code.

The second parameter is the ID of the document. You can get this from the URL.

For example:

docs.google.com/spreadsheets/d/1YnqCNZFqfdRP_7ocmAkD0dpI-G_bFnwGH1vN-YppAZE/edit#gid=835270728

Registration needs to happen when the app first starts up (before you write any data).

Add Attributes to Classes

Any class that needs to be written to or read from a Google Sheet, needs to be adorned with two attributes:

The Document attribute includes the name of the document passed to RegisterDocumentID (see above). This is the spreadsheet that will hold saved instances.

[Document("LogTest")]

The Sheet attribute contains the name of the sheet (tab) to read from or write to.

[Sheet("Today's Results")]

Object Persistence

Specify the properties and fields to read/write using the column attribute, like this:

[Column]
public DateTime Time { get; set; }

In this case, the column header will be "Time". If you want to use a different column name, pass that string in as a parameter to the column attribute, like this:

[Column("Sale Price")]
public decimal Price { get; set; }

You can specify an indexer property (which must have unique values in the spreadsheet), like this:

[Indexer]
[Column]
public Guid ID { get; set; }

If a class has an indexer, when you save it, it will overwrite the data on row where that class data previously existed.

Saving

To save objects adorned with the Document and Sheet attributes (see above), simply call:

GoogleSheets.SaveChanges(...)

Passing the instance or instances you want to save. That's it.

Loading

To load data from a spreadsheet, use:

List<T> results = GoogleSheets.Get<T>()

Where T is the class that has been adorned with the Document and Sheet attributes. That's it.

Object Logging

Object logging is super cool. You can rapidly send many rich log messages to a spreadsheet that you can monitor from anywhere and share easily.

To log an object, call:

GoogleSheets.AppendRow(instance);

Where instance is an instance of the class that has been adorned with the Document and Sheet attributes.

Throttling

Object logging is throttled, so you can send many messages in a short time without exceeding Google API messaging quotas.

The default time between updates is 5 seconds. You can change it like this if you like:

GoogleSheets.TimeBetweenThrottledUpdates = TimeSpan.FromSeconds(10);

We do not recommend dropping this time below 2 seconds because of Google Api Messaging Quotas.

Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  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. 
.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 was computed. 
.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.

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
1.3.4 332 2/17/2023
1.3.3 272 1/28/2023
1.3.1 439 3/18/2022
1.3.0 393 3/18/2022
1.2.0-alpha 150 2/14/2022
1.0.0-alpha 132 2/10/2022
0.9.0-alpha 146 2/8/2022

Initial