0

I am working on accessing the google spreadsheet. I was able to read the data from google spread using C# code.I was able to get the collection of values with in the given range of spreadsheet. I was researched on this cell address but i didn't find the solution.

My Requirement is i want to get the cell value and corresponding cell address.

How can I do it? I was stuck with this from past few days.Please help me out from this issue.

Thanks in advance!

Here is my code :

      string applicationName = "*******";     

        var serviceaccountemail = "*******@*************.iam.gserviceaccount.com";

        var certificate = new X509Certificate2(GetCertificateBytes(), "notasecret", X509KeyStorageFlags.Exportable);

        ServiceAccountCredential credential = new ServiceAccountCredential(
          new ServiceAccountCredential.Initializer(serviceaccountemail)
          {
              Scopes = new[] { "https://spreadsheets.google.com/feeds" }
          }.FromCertificate(certificate));

        var service = new SheetsService(new BaseClientService.Initializer()
        {
            HttpClientInitializer = credential,
            ApplicationName = applicationName,
        });


        String spreadsheetId = "1mPir8cyjHBlSYjS4ROsyZBX7DocJlyATQdg58cLhmOI";
        String range = "Sheet1!A1:H";

        SpreadsheetsResource.ValuesResource.GetRequest request = 
            service.Spreadsheets.Values.Get(spreadsheetId, range);

        ValueRange response = request.Execute();

        IList<IList<Object>> values = response.Values;
prasanthi
  • 562
  • 1
  • 9
  • 25
  • Can you share the code which gets collection values within the given range of spreadsheet? – Chetan Oct 10 '17 at 06:37
  • Thank for Reply@ChetanRanpariya , I have added the code in the above post it self . – prasanthi Oct 10 '17 at 13:50
  • Try to use the code from the [SO thread](https://stackoverflow.com/a/2627368). This code will be able to get a value from a specified range. And you can perform this code from another [SO thread](https://stackoverflow.com/a/2630016) to get the cell address on a given range. From the code, the RangeAddress will take any Excel range and throw you back the address. – MαπμQμαπkγVπ.0 Oct 11 '17 at 12:12
  • Thanks for reply @MαπμQμαπkγVπ.0.I was looking for google spread sheet not for excel and In this SO thread , we need to specify the row and column but i don't know the row and column of the particular cell .I know only the range i.e., starting cell and ending cell of my data in google spread sheet. – prasanthi Oct 12 '17 at 06:23

0 Answers0