Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

323
Views
Google Sheets - How to get multiple row data by row index

I'm trying to find a way using the google sheet api to fetch a particular set of rows by their index.

As an example I have a list of row indexs: 15,16,20. I would like for only these rows data to be returned.

Everything I'm trying with the range selection isn't working. Is there some other method I can use for this, or is it just not possible?

SpreadsheetsResource.ValuesResource.GetRequest getRowsRequest =
        service.Spreadsheets.Values.Get(spreadsheetId, "Inbound!{A15:B15; A16:B16}");

ValueRange getRowsResponse = getRowsRequest.Execute();
IList<IList<Object>> valuestest = getRowsResponse.Values;

The API returns a returns an error for the above call stating 'Unable to parse range'.

Quite surprised how much work it is just to filter the data in google sheet by a col value and then access just the rows needed. Rather than just pulling every row down and checking programatically!

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You can use the batchGet method instead of simply get. It works pretty much in the same way that get does but it lets you specify a list of ranges.

You could modify your code to something like:

List<string> ranges = new List<string>{"Inbound!A15:B15", "Inbound!A16:B16"};
//POPULATE THIS LIST WITH YOUR RANGES

SpreadsheetsResource.ValuesResource.BatchGetRequest 
    request = sheetsService.Spreadsheets.Values.BatchGet(spreadsheetId);

request.Ranges = ranges;

Data.BatchGetValuesResponse response = request.Execute();

You can find the documentation of the batchGet method, along with a C# example, here.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!