Wednesday 6 January 2021

How to avoid formula injection while keeping cell value in Javascript

How to avoid formula injection while keeping cell value in Javascript.

Is there a way to keep the value escaped in the formula editor, but show the correct value, without the leading single quote, in the cell?

I export excell and trying to avoid formula by changing the cell value.

Below is my code.

var cellValue = cell.value;
if( cellValue != null && "=-+@".indexOf(cellValue.charAt(0)) >= 0 ) {
     cell.value= "'"+cell.value;
}

Here I am trying to append single quote while exporting. But afetr export the single quote valeis still presentt in my cell.



from How to avoid formula injection while keeping cell value in Javascript

No comments:

Post a Comment