How to insert a list (Data) in google spreadsheet in c# ?

Before coding, create uri for your spreadsheet, see below setpes:
1.login to google drive and open your spreadsheet
2.Download spreadsheet through (File -> Dowanload as -> Webpage) then new page will be oped











3. collect spreadsheet id from querystring (see below )

4. this is uri 
https://spreadsheets.google.com/feeds/list/t04UA4wbOY42Aeyaar7WZdQ/od6/private/full
here  t04UA4wbOY42Aeyaar7WZdQ is spreadsheet id and od6 is sheet id ( sheet id Initial from od6 (sheet1), if sheet2 then od7 )

Namespace:
using Google.GData.Client;
using Google.GData.Spreadsheets;

Downlaod assembly from here and add to references folder

C# Code:
//user setUserCredential
//
string UserId = "softtechsolving@gmail.com"; // google account userid
string Password = "xxxxxxx";   // declare password to "xxxxxxx" of your google accout password
service.setUserCredentials(UserId,Password);
//

//DoListInsert
//
try
{
    ListEntry entry = new ListEntry();

    ListEntry.Custom custom = new ListEntry.Custom();
    custom.LocalName = "name"// here “name” is a column name
    custom.Value = "softtech" // input your data… like softtech
    entry.Elements.Add(custom);

    AtomEntry retEntry = service.Insert(new Uri("https://spreadsheets.google.com/feeds/list/t04UA4wbOY42Aeyaar7WZdQ/od6/private/full"), entry);
}
catch { }

//

Popular posts from this blog

How to protect your Drive/Flash USB Drive (Pen Drive) with Password without using any software