egeriis / zipcelx

Turns JSON data into `.xlsx` files in the browser
MIT License
294 stars 90 forks source link

Excel file containing ESCAPE character not opening in Microsoft Excel viewer #70

Open sudipta1411 opened 4 years ago

sudipta1411 commented 4 years ago

Hello, I am exceuting the following code var config = {"filename":"general-ledger-Q1","sheet":{"data":[[{"value":"Income - Webshop","type":"string"},{"value":"You have 3 missed Call\u001b<s\u001b> from +1234123412 Last call: 05-11-2019 11:56 ","type":"string"}]]}}; zipcelx(config)

The generated XLSX file is not opened in Microsoft Excel Viewer, whereas it is opening in Google docs and WPS Office. I am guessing the presence of \u001b (ESCAPE) character is the root of the problrm. Any idea what to do? Thanks

catamphetamine commented 3 years ago

Note to devs:

One could decode "escape characters" like this:

import unraw from "unraw";

let step1 = unraw('http\\u00253A\\u00252F\\u00252Fexample.com');
// yields "http%3A%2F%2Fexample.com"
// Then you can use decodeURIComponent to further decode it:
let step2 = decodeURIComponent(step1);
// yields http://example.com
catamphetamine commented 3 years ago

@sudipta1411 How did "escape characters" end up in your data in the first place? Perhaps you should first unraw() it and then call this library's functions.