0

I want to be able to retrieve all the sheets' (sheet1,sheet2,...etc) data from Google Sheets, not just one sheet (sheet1, in this example):

   from("timer:run?repeatCount=1")
      .to("google-sheets://data/get?spreadsheetId=1i8jAVG3r6BINzdU0NzgAIuDUuz3FiVRyFF1Wm6WQq_0&range='Camel Sheet1'")
      .log("${body}")
      .convertBodyTo(String.class)
      .process(new TransformerGoogleSheets())
      .to("file:file/Input?fileName=employee.csv")
      .log("Sucess");

I searched on Apache Camel's website but I couldn't get relevant solution.

1 Answer 1

1

Looks like you want to use the getBatch method instead of get:

from("timer:run?repeatCount=1")
      .to("google-sheets://data/getBatch?spreadsheetId=1i8jAVG3r6BINzdU0NzgAIuDUuz3FiVRyFF1Wm6WQq_0")
      .log("${body}")
      .convertBodyTo(String.class)
      .process(new TransformerGoogleSheets())
      .to("file:file/Input?fileName=employee.csv")
      .log("Sucess");

I didn't use the google-sheets api yet, but probably you will get a list of ranges as a response. You can then split the body with .split(body()) and then process every range like you are doing now. You should get the structure of the response by analyzing your logged ${body}.

With the batchGet method you only have to specify the spreadsheetId and you can omit the range.

https://camel.apache.org/components/4.4.x/google-sheets-component.html#_api_data_method_batchGet

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.