Googlesheet APIv4 getting empty cells

后端 未结 9 1494
我寻月下人不归
我寻月下人不归 2021-01-03 22:03

I have a googlesheet where a column may contain no information in it. While iterating through the rows and looking at that column, if the column is blank, it\'s not returni

9条回答
  •  被撕碎了的回忆
    2021-01-03 22:25

    I experienced the same issue using V4 of the sheets api but was able to workaround this using an extra column at the end of my range and the valueRenderOption argument for the values.get API

    Given three columns, A, B and C any of which might contain a null value, add an additional column, D and add an arbitrary value here such as 'blank'.

    Ensure you capture the new column in your range and add the additional parameter,

    valueRenderOption: 'FORMATTED_VALUE'.

    You should end up with a call similar to this:

    sheets.spreadsheets.values.get({
      spreadsheetId: SOME_SHEET_ID,
      range: "AUTOMATION!A:D",
      valueRenderOption: 'FORMATTED_VALUE'
    }, (err, res) => {})
    

    This should then give you a consistent length array for each value, returning a blank string "" in the place of the empty cell value.

提交回复
热议问题