src/js/common/clipboardUtil.js
function(table) {
        var data = [];
        var rows = table.rows;
        var index = 0;
        var length = rows.length;
        var columnIndex, colspanRange, rowspanRange;

        // Step 1: Init the data matrix
        for (; index < length; index += 1) {
            data[index] = [];
        }

        // Step 2: Traverse the table
        _.each(rows, function(tr, rowIndex) {
            columnIndex = 0;

            _.each(tr.cells, function(td) {
                var text = td.textContent || td.innerText;

                while (data[rowIndex][columnIndex]) {
                    columnIndex += 1;
                }

                colspanRange = [columnIndex, columnIndex + (td.colSpan || 1)];
                rowspanRange = [rowIndex, rowIndex + (td.rowSpan || 1)];

                // Step 3: Set the value of td element to the data matrix as colspan and rowspan ranges
                setDataInSpanRange(text, data, colspanRange, rowspanRange);

                columnIndex = colspanRange[1];
            });
        });

        return data;
    }
function(table) {
        var data = [];
        var rows = table.rows;
        var index = 0;
        var length = rows.length;
        var columnIndex, colspanRange, rowspanRange;

        // Step 1: Init the data matrix
        for (; index < length; index += 1) {
            data[index] = [];
        }

        // Step 2: Traverse the table
        _.each(rows, function(tr, rowIndex) {
            columnIndex = 0;

            _.each(tr.cells, function(td) {
                var text = td.textContent || td.innerText;

                while (data[rowIndex][columnIndex]) {
                    columnIndex += 1;
                }

                colspanRange = [columnIndex, columnIndex + (td.colSpan || 1)];
                rowspanRange = [rowIndex, rowIndex + (td.rowSpan || 1)];

                // Step 3: Set the value of td element to the data matrix as colspan and rowspan ranges
                setDataInSpanRange(text, data, colspanRange, rowspanRange);

                columnIndex = colspanRange[1];
            });
        });

        return data;
    }
function ( table ) { var data = [ ] ; var rows = table . rows ; var index = 0 ; var length = rows . length ; var columnIndex , colspanRange , rowspanRange ; // Step 1: Init the data matrix for ( ; index < length ; index += 1 ) { data [ index ] = [ ] ; } // Step 2: Traverse the table _ . each ( rows , function ( tr , rowIndex ) { columnIndex = 0 ; _ . each ( tr . cells , function ( td ) { var text = td . textContent || td . innerText ; while ( data [ rowIndex ] [ columnIndex ] ) { columnIndex += 1 ; } colspanRange = [ columnIndex , columnIndex + ( td . colSpan || 1 ) ] ; rowspanRange = [ rowIndex , rowIndex + ( td . rowSpan || 1 ) ] ; // Step 3: Set the value of td element to the data matrix as colspan and rowspan ranges setDataInSpanRange ( text , data , colspanRange , rowspanRange ) ; columnIndex = colspanRange [ 1 ] ; } ) ; } ) ; return data ; }
Convert cell data of table to clipboard data
@param {HTMLElement} table - Table element
@returns {array} clipboard data (2*2 matrix)
Convert cell data of table to clipboard data