theoephraim / node-google-spreadsheet

Google Sheets API wrapper for Javascript / Typescript
https://theoephraim.github.io/node-google-spreadsheet
The Unlicense
2.26k stars 382 forks source link

Bug - Unfreeze rows and columns doesn't work #672

Open MathRobin opened 6 months ago

MathRobin commented 6 months ago

I'm stucked with a gsheets i want to update because there are some rows and columns frozen.

I found this:

await worksheet.updateProperties({
  gridProperties: {
    frozenColumnCount: 0,
    frozenRowCount: 0,
  }
});

and it's "shorthand"

await worksheet.updateGridProperties({
  frozenColumnCount: 0,
  frozenRowCount: 0,
});

But in the two cases, it still say that i can't delete row frozen.

MathRobin commented 6 months ago

Ok, i found the problem, it's inside updateProperties method. It generates this call:

await worksheet._makeSingleUpdateRequest('updateSheetProperties', {
    properties: {
      sheetId,
      gridProperties: {
        frozenColumnCount: 0,
        frozenRowCount: 0,
      },
    },
    fields: 'gridProperties',
  });

when it should do this:

await worksheet._makeSingleUpdateRequest('updateSheetProperties', {
    properties: {
      sheetId,
      gridProperties: {
        frozenColumnCount: 0,
        frozenRowCount: 0,
      },
    },
-    fields: 'gridProperties',
+    fields: 'gridProperties.frozenColumnCount,gridProperties.frozenRowCount',
  });

Fields is not able to get the correct path of fields. Could be a good subject of PR