Closed WJurecki closed 4 years ago
Thanks for digging in, @WJurecki !! The approach that I'd want to ideally take is just to alter the functionality of Export-GSSheet
so that passing the -Append
switch uses the Append()
method instead. Any reasoning around why that may not be desirable for your case? Genuinely curious as there's definite value in using the Append()
method for that case, but I could also see it introducing breaking changes maybe if there is anyone (like myself tbh) that are using it with the range defined already? May be a non-issue if the range provided is empty though, which would be the case for anyone using it the same way I am and calculating the start row before submitting the Export-GSSheet
call.
@scrthq, I can certainly see the desire to wrap it into Export-GSSheet
.
The only downside that I see would be breaking anyone's existing use.
While I believe Append()
method would give the same result within the sheet when applied against an empty range, Append()
gives a different Response Body than BatchUpdate()
and this very-well may be the cause of breakage.
I'm willing to accept any solution, I just didn't want to have to keep figuring out where to add data to the end of a table and that's why I created the solution that I proposed.
@WJurecki I appreciate the solid feedback!! I'll need to do some testing. If another function is needed, I'll likely extract the Values
builder logic into a private function because that's a lot of painful code to have replicated across.
hey @WJurecki - I didn't forget about this, hoping to finally start testing things soon. I'll keep you updated!
Alrighty, did some digging after testing a bit and cleaned up the function you provided so it would pass the CI tests (wasn't much needed, thank you for that!). Add-GSSheetValues
has been deployed in v2.35.0!
I would like to be able to use the google API Method: spreadsheets.values.append to add rows to an existing table in a google sheet
Create a function
Add-GSSheetValues
I attempted to use the existing
Export-GSSheet
but this requires me to determine and specify the exact range where the new values will be inserted. Using the google API Method: spreadsheets.values.append an entire sheet can be specified in the range and the API "finds" the end of an existing table and places the appended data in appropriate rows.Either I have entirely missed how to add rows to the end of a table or this capability is not currently existing in PSGSuite.
I have taken the liberty to copy and modify the code for
Export-GSSheet
to create a new functionAdd-GSSheetValues
and have tested it for my limited use case.Please note that I used the API Enums rather than ValidateSet so options my be slightly different from the rest of PSGSuite. Obviously make these however you see fit and I will adapt to your released version (assuming you accept my Feature request.)