Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

324
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda