import ExcelJS from 'exceljs'
onmessage = (res) => {
    let { arr, sk, worksheet } = res.data
    /**
 *  处理超过26个字母的列
 * @param {*} number 
 * @returns 
 */
    function getLetter(number) {
        if (number < 26) {
            return letter[number];
        } else {
            let n = number % 26
            let l = Math.floor(number % 26)
            return letter[l] + letter[n]
        }
    }
    /**
 * 占多行的数组
 * @param {*} arr 
 * @param {*} sk 
 */
    function setArrayContent(arr, sk) {
        /**
         *  循环二维数组,在循环行  
         */
        let al = arr.length;
        let sl = al - 1;
        console.log('gssgg');
        for (let i = 0; i < arr.length; i++) {
            let lcomunNow = worksheet.getRow(lcomun);
            for (let v = 0; v < arr[i].length; v++) {
                lcomunNow.getCell(getLetter(sk + v)).value = arr[i][v];
                lcomunNow.getCell(getLetter(sk + v)).border = { top: { style: 'thin' }, left: { style: 'thin' }, bottom: { style: 'thin' }, right: { style: 'thin' } };
                lcomunNow.alignment = { vertical: 'middle', horizontal: 'center' };
            }
            lcomunNow.height = 25;
            lcomunNow.commit()
            if (i < sl) lcomun++
        }
    }

    setArrayContent(arr, sk)
    postMessage('ok')
}