3

i'm using the gspread module and when i try to append new row, with some values, using the code below:

sheet.append_row(['image1', '=IMAGE()'])

it inputs the values in the next available row (as expected) but in the cell that's supposed to have =IMAGE() value, it has '=IMAGE()

it is preceded by a single quote.

the first cell is fine, with image1 as intended, without any single quote.

why is that so? how do i remove it?

Julliard
  • 523
  • 1
  • 6
  • 23

1 Answers1

3
  • You want to put =IMAGE() as a formula. It's not '=IMAGE().

If my understanding is correct, how about this modification?

sheet.append_row(['image1', '=IMAGE()'], value_input_option='USER_ENTERED')

or

sheet.append_row(['image1', '=IMAGE()'], 'USER_ENTERED')

References:

Although in my environment, I can use such way, if this didn't work in your environment, I'm sorry.

Tanaike
  • 181,128
  • 11
  • 97
  • 165
  • unfortunately, both "RAW" and "USER_ENTERED" did not help. but thanks! – Julliard Jan 14 '19 at 11:18
  • @Kwok Wen Jian Thank you for replying. I'm really sorry for the inconvenience. I understood about your question as follows. "You want to put ``=IMAGE()`` as a formula. It's not ``'=IMAGE().``". If I misunderstand your question, please tell me. I would like to modify it. – Tanaike Jan 14 '19 at 22:01
  • you understood it perfectly, I want the input to be =IMAGE() and not '=IMAGE() – Julliard Jan 15 '19 at 08:39
  • @Kwok Wen Jian Thank you for replying. I'm sorry for the inconvenience. In my environment, I can confirm that ``sheet.append_row(['image1', '=IMAGE()'], value_input_option='USER_ENTERED')`` works. ``=IMAGE()`` is put as a formula. So in order to correctly understand your situation, can you provide your script? If you can do, please add it to your question. I would like to check it. – Tanaike Jan 15 '19 at 08:45
  • @Kwok Wen Jian By the way, although I'm not sure whether this is related to the current issue, if you are using old version of gspread, can you update to the latest one and try it again? The current version is v3.1.0. – Tanaike Jan 15 '19 at 08:50
  • i have switched to: reportSheet.update_acell('E%s'%(next_row), '=IMAGE(\"{}\")'.format(photo_file['file_path'])) and the code works for me. Still, I believe it worked in your environment, i shall mark your answer as right – Julliard Jan 15 '19 at 09:19
  • Thank you for your additional information. When I found the same situation, I would like to add the information. I could obtain the important experience from your question. Thank you, too. – Tanaike Jan 15 '19 at 23:30
  • For anyone looking through comments, hopefully my answer edit is accepted that says you should be using gspread version 4.0.0 or greater, which added the ability to use user_input_option. This was likely the cause for the inability of author to reproduce, and the asker to succeed. – weezilla Aug 06 '21 at 07:15