Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get the values and their cell range for each one for updating one row later #1

Open
kabeza opened this issue Apr 14, 2023 · 1 comment

Comments

@kabeza
Copy link

kabeza commented Apr 14, 2023

Hi Nico
Not an issue but a question:

I call $response->get_values(); and all works fine, but I'd like to get the cell range for the values in specific column

Let's say I'd like to modify a row, right? I have a column with people's SSN (social security number) which is a univocal data.
I want to modify a person's name/surname for a specific SSN, but I don't know where is that row located in the Spreadsheet...
Therefore I must search this SSN value before modifying it and get its location in the SpreadSheet, eg Sheet1!D18

Is there a way to search in the SpreadSheet and get the cell for the specific value searched? Or to get all the values with their corresponding cell range/location ...?

Thanks a lot in advance,

PS: Excellent article/post. Very detailed/useful
https://www.nidup.io/blog/manipulate-google-sheets-in-php-with-api

@tacman
Copy link

tacman commented May 12, 2024

you'd want to read the data and create a hash of the row indexes for each value. If you know the field is unique, like SSN, you can just create the list pointing to a row, then use that data to update.

$ssnToRow = [
   '123' => 'A1',
   '234' => 'A2'
];

then update the row ->update($ssnToRow['234'], [new values])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants