jspreadsheet / ce

Jspreadsheet is a lightweight vanilla javascript plugin to create amazing web-based interactive tables and spreadsheets compatible with other spreadsheet software.
https://bossanova.uk/jspreadsheet/v4
MIT License
6.71k stars 820 forks source link

Copying formulas instead of results #391

Closed iceBBBB closed 5 years ago

iceBBBB commented 5 years ago

I have a formula (=F3*B3) set in cell and if i want copy result (to another input, in form on page), it will copied formula but no result number. Is it possible to copy (CTRL+C) result number? Thanks

I really like your project! <3

pphod commented 5 years ago

Please, download from the master repository, and apply copyCompatibility:true as below:

    jexcel(document.getElementById('spreadsheet'), {
        data:data,
        columns: [
            { type: 'text', title:'Product', width:'300' },
            { type: 'text', title:'Qtd', width:'80' },
            { type: 'text', title:'Price', width:'100', mask:'#.##,00', decimal:',' },
            { type: 'text', title:'Total', width:'100' },
        ],
        updateTable:function(instance, cell, col, row, val, label, cellName) {
            if (cell.innerHTML == 'Total') {
                cell.parentNode.style.backgroundColor = '#fffaa3';
            }

            if (col == 3) {
                if (parseFloat(label) > 10) {
                    cell.style.color = 'red';
                }  else {
                    cell.style.color = 'green';
                }
            }
        },
        columnSorting:false,
        copyCompatibility:true,
    });
pphod commented 5 years ago

The copy will behave like excel and google spreadsheet. The default is false, so will copy the formulas and ids from dropdowns.