packages/opal-node-msexcel/msexcel.js
function readRows(ws, rows, opts) {
        let contents = {};
        if (typeof rows === 'string') {
            rows = rows.split(',');
        }
        opts = (opts === undefined) ? {} : opts;
        // console.log('Typeof Rows %s', typeof rows);
        // console.log('Typeof Rows %s', rows);
        // console.log('Length Rows %d', rows.length);
        let dRange = xlsx.utils.decode_range(ws['!ref']);
        for (let i = 0; i < rows.length; ++i) {
            // console.log('rows[%d]=%s', i, rows[i]);
            let dRow = xlsx.utils.decode_row(rows[i]);
            for (let C = dRange.s.c; C <= dRange.e.c; ++C) {
                let encCell = xlsx.utils.encode_cell({c: C, r: dRow});
                contents[encCell] = ws[encCell] || {};
            }
        }
        contents['!ref'] = ws['!ref'];

        if (opts.asis) {
            return contents;
        }

        Object.assign(opts, {
            header: 1,
            raw: true,
            blankrows: true,
        });

        opts.header = opts.useLabel ? 'A' : opts.header;

        let contentsJson = xlsx.utils.sheet_to_json(contents, opts);

        if (opts.removeEmpty) {
            contentsJson = contentsJson.filter((row) => {
                // console.log(typeof row);
                return check.object(row) ?
                    check.nonEmptyObject(row) : check.nonEmptyArray(row);
            });
        }

        return contentsJson;
    }
function readRows(ws, rows, opts) {
        let contents = {};
        if (typeof rows === 'string') {
            rows = rows.split(',');
        }
        opts = (opts === undefined) ? {} : opts;
        // console.log('Typeof Rows %s', typeof rows);
        // console.log('Typeof Rows %s', rows);
        // console.log('Length Rows %d', rows.length);
        let dRange = xlsx.utils.decode_range(ws['!ref']);
        for (let i = 0; i < rows.length; ++i) {
            // console.log('rows[%d]=%s', i, rows[i]);
            let dRow = xlsx.utils.decode_row(rows[i]);
            for (let C = dRange.s.c; C <= dRange.e.c; ++C) {
                let encCell = xlsx.utils.encode_cell({c: C, r: dRow});
                contents[encCell] = ws[encCell] || {};
            }
        }
        contents['!ref'] = ws['!ref'];

        if (opts.asis) {
            return contents;
        }

        Object.assign(opts, {
            header: 1,
            raw: true,
            blankrows: true,
        });

        opts.header = opts.useLabel ? 'A' : opts.header;

        let contentsJson = xlsx.utils.sheet_to_json(contents, opts);

        if (opts.removeEmpty) {
            contentsJson = contentsJson.filter((row) => {
                // console.log(typeof row);
                return check.object(row) ?
                    check.nonEmptyObject(row) : check.nonEmptyArray(row);
            });
        }

        return contentsJson;
    }
function readRows ( ws , rows , opts ) { let contents = { } ; if ( typeof rows === 'string' ) { rows = rows . split ( ',' ) ; } opts = ( opts === undefined ) ? { } : opts ; // console.log('Typeof Rows %s', typeof rows); // console.log('Typeof Rows %s', rows); // console.log('Length Rows %d', rows.length); let dRange = xlsx . utils . decode_range ( ws [ '!ref' ] ) ; for ( let i = 0 ; i < rows . length ; ++ i ) { // console.log('rows[%d]=%s', i, rows[i]); let dRow = xlsx . utils . decode_row ( rows [ i ] ) ; for ( let C = dRange . s . c ; C <= dRange . e . c ; ++ C ) { let encCell = xlsx . utils . encode_cell ( { c : C , r : dRow } ) ; contents [ encCell ] = ws [ encCell ] || { } ; } } contents [ '!ref' ] = ws [ '!ref' ] ; if ( opts . asis ) { return contents ; } Object . assign ( opts , { header : 1 , raw : true , blankrows : true , } ) ; opts . header = opts . useLabel ? 'A' : opts . header ; let contentsJson = xlsx . utils . sheet_to_json ( contents , opts ) ; if ( opts . removeEmpty ) { contentsJson = contentsJson . filter ( ( row ) => { // console.log(typeof row); return check . object ( row ) ? check . nonEmptyObject ( row ) : check . nonEmptyArray ( row ) ; } ) ; } return contentsJson ; }
reads a specified rows from an opened workbook
@function
@param {object} ws - worksheet.
@param {object} rows - rows to be fetched.
@param {{asis: bool,
useLabel: boolean,
header: string,
removeEmpty:boolean}} opts - options for processing the read request
@return {object} contentsJson - returns the fetched content as a JSON
reads a specified rows from an opened workbook