Closed darma-exe closed 1 year ago
@darma-exe,
In the SheetHelper
class you can use the BatchUpdate(List<BatchUpdateRequestObject> updates)
method. You pass it a collection of updates and you can update multiple cells with that method. Is this what you are looking for?
Also if you are using the strongly typed option, the BaseRespository
and BaseRecord
classes let you do this,
firstRecord.PriceAmount = 99.99;
repository.SaveField(firstRecord, (r) => r.PriceAmount);
Thanks for the support.
I was able to write using the SheetHelper::BatchUpdate()
method.
If I don't want to overwrite an existing style (e.g. color) of a cell, do I need to get the existing style beforehand?
I had never tested this before with formatted cells. You are right, the existing formats get reset when you make this call. I'm not sure how to tell the Google Sheets API to use the existing formatting but only update the value of the cell. You can specify the formatting in the CellData property when you call the batch update method though.
Also I found a bug in the batch update method I previously wrote. I just updated that with version 1.0.40 so make sure to update to that nuget version.
Just updated the BatchUpdate method to only update the specified user entered value vs the formatting of the cell. I will update the method later to let you change which fields you want to modify. But for now this will support the use case of not changing existing formats if they have already been applied.
Check out version 1.0.41 on nuget now.
One last update! In 1.0.42 you can now specify a custom field mask. If you use "*", that will update every property of the cells in the request. The method defaults to only updating the userEnteredValue. But you can override that now.
I added some documentation to the readme file to explain the different field masks you can use here,
https://github.com/SteveWinward/GoogleSheetsWrapper#batch-updates
Thank you for your great library.
Does a way to update row content already exist on the library?
I envision a use case where a particular range is kept up to date using
SheetHelper::ClearRange()
and the update method.