Meta information

Meta information is a feature to help keep arbitrary hidden information about the cells. There is no interface to define any meta information. That should be done programmatically.

Documentation

Methods

Methods related to manage the spreadsheet meta information.
MethodDescription
getMeta Get the meta information from a cell or from the whole spreadsheet.
getMeta(cellName: String | null)
@Param mixed - cell identification or null for the whole table.
setMeta Set the meta information for a single cell by name or for multiple cells.
setMeta(cellName: Mixed | Array, key: String, value: String)
@param {string|Object} - Identication of an cell or an array of objects with multiple cell meta information.
@param {string=} k - the key string to identify the meta information.
@param {string=} v - the value string with the meta information.


Events

EventDescription
onchangemetaonchangemeta(worksheet: Object, newValue: Object) : void


Initial Settings

The meta property defines the worksheet cells meta information.
PropertyDescription
meta: ObjectInitial meta information.


Examples

Basic example using the meta information native methods.




It is possible to interact with any meta-information during the initialization or programmatically using the methods: getMeta or setMeta.





Source code

<html>
<script src="https://jspreadsheet.com/v8/jspreadsheet.js"></script>
<script src="https://jsuites.net/v4/jsuites.js"></script>
<link rel="stylesheet" href="https://jspreadsheet.com/v8/jspreadsheet.css" type="text/css" />
<link rel="stylesheet" href="https://jsuites.net/v4/jsuites.css" type="text/css" />

<div id="spreadsheet"></div>

<script>
var data = [
    ['US', 'Apples', 'Yes', '2019-02-12'],
    ['CA;US;UK', 'Carrots', 'Yes', '2019-03-01'],
    ['CA;BR', 'Oranges', 'No', '2018-11-10'],
    ['BR', 'Coconuts', 'Yes', '2019-01-12'],
];

var table = jspreadsheet(document.getElementById('spreadsheet'), {
    data:data,
    columns: [
        { type: 'dropdown', title: 'Product Origin', width: '300px', url: '/jexcel/countries', autocomplete: true, multiple: true },
        { type: 'text', title: 'Description', width: '200px' },
        { type: 'dropdown', title: 'Stock', width: '100px', source: ['No','Yes'] },
        { type: 'calendar', title: 'Best before', width: '100px' },
    ],
    meta:{
        A1: { myMeta: 'this is just a test', otherMetaInformation: 'other test' },
        A2: { info: 'test' }
    },
    allowComments: true,
});
</script>

<button type="button" onclick="table.setMeta({ C1: { id:'1', y:'2019' }, C2: { id:'2' } });">Set meta data for multiple columns</button>
<button type="button" onclick="table.setMeta('B2', 'myMetaData', prompt('myMetaData:'));">Set a meta information for B2</button>
<button type="button" onclick="document.getElementById('console').value = JSON.stringify(table.getMeta('A1'));">Get the meta information for A1</button>
<button type="button" onclick="document.getElementById('console').value  = JSON.stringify(table.getMeta());">Get all meta information</button>

</html>