function encodeToSpreadsheetStr(arr) {
    let r;
    let rLen;
    let c;
    let cLen;
    let str = "";
    let val;

    for (r = 0, rLen = arr.length; r < rLen; r += 1) {
        cLen = arr[r].length;

        for (c = 0; c < cLen; c += 1) {
            if (c > 0) {
                str += "\t";
            }
            val = arr[r][c];

            if (typeof val === "string") {
                if (val.indexOf("\n") > -1) {
                    str += `"${val.replace(/"/g, '""')}"`;
                } else {
                    str += val;
                }
            } else if (val === null || val === void 0) {
                // void 0 resolves to undefined
                str += "";
            } else {
                str += val;
            }
        }

        if (r !== rLen - 1) {
            str += "\n";
        }
    }

    return str;
}
@decodeSpreadsheetStr
@desc encode array to spreadsheet string.  refer from http://github.com/warpech/sheetclip/
@param {array} str The string to parse.
@returns {string}