I have the following line on my sendEmail function in google app script
tempo.getRange(lastRow, 12).setFormula('="www.sample"&R[0]C[-1]&"collection.com"');
some of the result has space in between like this
www.samplespot lightcollection.com
which is resulting for a hyperlink to break.
Can someone in help replacing the space with using google appscript?
The final result should look like this
www.samplespot lightcollection.com
CodePudding user response:
Although I'm not sure whether I could correctly understand your expected result, how about the following modification?
From:
tempo.getRange(lastRow, 12).setFormula('="www.sample"&R[0]C[-1]&"collection.com"');
To:
tempo.getRange(lastRow, 12).setFormula('=ENCODEURL("www.sample"&R[0]C[-1]&"collection.com")');
- In this case, when the value of last row of column "K" is
spot light
, the column "L" showswww.samplespot lightcollection.com
.
Reference:
CodePudding user response:
Just use a for loop:
a = list('www.samplespot lightcollection.com')
for b, c in enumerate(a):
if c == ' ':
a[b] = ' '
a = ''.join(a)
print(a)
Can be shortened into a function:
replace = lambda a: ''.join([' ' if c == ' ' else c for b, c in enumerate(list(a))])
print(replace('www.samplespot lightcollection.com'))