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 cell format when reading from a Google Spreadsheet #186

Open
padma295 opened this issue Feb 24, 2018 · 4 comments
Open

Get cell format when reading from a Google Spreadsheet #186

padma295 opened this issue Feb 24, 2018 · 4 comments
Labels

Comments

@padma295
Copy link

@padma295 padma295 commented Feb 24, 2018

Dear Team,

First of all, thanks a lot for this API. It is saving a lot of time when I try to pull out data from a Google Spreadsheet or update data.

I would like to know if it is possible to detect the format of a particular cell range/row/cell when reading from gsheet. Is it possible to read only the Bold font items or exclude strike-through items or read only a particular coloured rows using this app. I did find API docs on setting formatting for cells but did not find anything for getting the formats.

Thanks,
Padma

@nithinmurali
Copy link
Owner

@nithinmurali nithinmurali commented Feb 26, 2018

Hi Padma,
when you create a cell, only the value of the cell will be set, if you want to get all the cell properties call the fetch function. Now for getting formats, the properties are not documented, thanks for letting us know.

c1 = wks.Cell('A1')
c1.fetch()
c1.text_format['bold'] 

Now about getting only data based on format, I don't think pygsheets can do that. Also i am doubt full if the even the raw api can do it. Incase you find a way please let us know.

@Kordishal
Copy link
Contributor

@Kordishal Kordishal commented Mar 15, 2018

I don't think the API can get data based on format, but we could implement functions which allow for easier access to the format params (e.g. a bold property etc.) The question is if many people would want that and how far we would want do bring this.

Then it would be possible to create a spreadsheet/worksheet function which can filter based on various properties. (e.g. get only CENTER aligned cells). This would be a functionality just in pygsheets and would be fully independent of the API.

@nithinmurali
Copy link
Owner

@nithinmurali nithinmurali commented Mar 15, 2018

@Kordishal yes it can be achieved like that. But i am not sure if many people would want that. And by adding each format as property we would be polluting the cell object.

@Kordishal
Copy link
Contributor

@Kordishal Kordishal commented Mar 15, 2018

The alternative would be to have a spreadsheet/worksheet function which like filter(attribute, value) where the attribute refers to a specific format attribute as string and the value you are looking for.

Without implementing all the attributes, but based on keys. This way would simply need to properly document this filter function but not add more properties on cell. It would then return a list of cells which have the specified value in this attribute.

Example: filter('strikethrough', False) -> return all items which have strikethrough set so false.

An implementation would then assume all unspecified values to not be present. Since most of the format values are implemented as dictionaries anyway this would not be the biggest problem.

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.