Most frequently asked questions and answers


  1. Jspreadsheet converts a string to a number.

  2. This is because autoCasting is set as default. It tries to improve the calculations by converting a string to a number. Solution: set autoCasting: false as a property in the column definitions.

    ...
    columns: [{
        type:'text', autoCasting: false
    }]
    
  3. What is the best way to create odd/even rows in an online spreadsheets?

  4. Solution: Add the following CSS code to your project.

    .jss tbody tr:nth-child(even) {
      background-color: #EEE9F1 !important;
    }
    
  5. How do I transform multiple HTML static tables to dynamic Jspreadsheet tables?

  6. var tables = document.querySelectorAll('table');
    for (var i = 0; i < tables.length; i++) {
        jspreadsheet(tables[i]);
    }
    
  7. How do I disable paste over a JSS spreadsheet?

  8. jspreadsheet(document.getElementById('spreadsheet'), {
        worksheets: [{
            minDimensions: [6,6],
        }],
        onbeforepaste: function(instance, data, x, y) {
            return false;
        }
    });
    
  9. How can I intercept and change a pasted string over a JSS spreadsheet?

  10. jspreadsheet(document.getElementById('spreadsheet'), {
        worksheets: [{
            minDimensions: [6,6],
        }],
        onbeforepaste: function(instance, data, x, y) {
            data = data.replace(',', '.', data);
            return data;
        }
    });
    
  11. How do I overwrite a type of a cell over a column type?

  12. jspreadsheet(document.getElementById('spreadsheet'), {
        worksheets: [{
            columns: [
                { type: 'text' },
                { type: 'text' }, 
            ],
            cells: {
                B2: { type:'number', mask:'$ #,##0.00', decimal:'.' },
                B3: { type:'percent' },
            }
        }
    });
    
    NOTE: Only available from Jspreadsheet Pro v7.
  13. How do I disabled the JavaScript contextmenu in my spreadsheet?

  14. jspreadsheet(document.getElementById('spreadsheet'), {
        worksheets: [{
            columns: [
                { type: 'text' },
                { type: 'text' }, 
            ],
            cells: {
                B2: { type:'number', mask:'$ #,##0.00', decimal:'.' },
                B3: { type:'percent' },
            }
        },
        contextMenu: function() {
            return false;
        }
    });
    
  15. How do I change the default download filename?

  16. jspreadsheet(document.getElementById('spreadsheet'), {
        worksheets: [{
            minDimensions: [6,6],
        }],
        csvFileName: 'yourname'
    });
    
  17. How do I add an external action without losing the spreadsheet focus?

  18. Working example:

    https://jsfiddle.net/spreadsheet/v5tbxg01/
  19. How do I keep the selection in the spreadsheet when clicking on an element outside the sheet?

  20. Add a class to the external element: jss_object

    https://jsfiddle.net/spreadsheet/rg1tdh0z/
  21. How do I automatic align numbers to the right using JSS spreadsheet?

  22. Working example:

    https://jsfiddle.net/spreadsheet/Lfxm6qw1/
  23. How do I automatic add unique ID to the cells?

  24. Working example:

    https://jsfiddle.net/spreadsheet/8svzf9pc/