DEV Community

Cover image for Google Sheets API in ASP.NET | C#
Techtolia
Techtolia

Posted on • Originally published at techtolia.Medium

Google Sheets API in ASP.NET | C#

Demo: https://techtolia.com/GoogleSheets/

With integrating the module to your ASP.NET web forms, read/write/update any google sheet that is shared you.

Present any google sheet on your web site with editable or static versions. Editable table feautures:

  • Edit cells
  • Clean Column
  • Delete Column
  • Insert Column Left
  • Insert Column Right
  • Clean Row
  • Delete Row
  • Insert Row Above
  • Insert Row Below

The module uses Google Sheets API with NuGet Packs.

Full source code is included.

What is Google Sheets API?

The Google Sheets API lets you read and modify any aspect of a spreadsheet. Spreadsheets have many settings that let you craft beautiful and functional sheets, so the API has many settings too.

Spreadsheets can have multiple sheets, with each sheet having any number of rows or columns. A cell is a location at the intersection of a particular row and column, and may contain a data value. The Google Sheets API provides the spreadsheets.values collection to enable the simple reading and writing of values.

To read data from a sheet, you will need the spreadsheet ID and the range(s) A1 notation.

To write to a sheet, you will need the spreadsheet ID, the range(s) in A1 notation, and the data you wish to write arranged in an appropriate request body object.

Google Sheets API in ASP.NET | C#Google Sheets API in ASP.NET | C#

Quick Start

  • Create a project on Google APIs Console.
  • Enable Google Sheets API & create credentials file. Copy the credentials file to your project.
  • Create a spreadsheet on Google Sheets and share it with edit access to your client_email that is in the credentials file.
  • Install Google Sheets library from NuGet.
  • Use source code and customize your web form.
  • Run the application.

Top comments (3)

Collapse
 
theemava profile image
Marvelus

Where is the full source?

Collapse
 
techt01ia profile image
Techtolia

Hi Marvelus, You can purchase the full source code on CodeCanyon 1.envato.market/kDEbx

Collapse
 
chris_switalski profile image
Chris Switalski

Great article. For simple use-cases, check out sheetdb.io, it is a tool that makes Google Spreadsheet a REST API and takes care of OAuth2 for you.