ce
ce copied to clipboard
JSON data(key/value pair) support in JExcel ?
Is there any future roadmap for supporting JSON data(key/value pair) in JExcel ? Btw kudos to developer for the library.
I've been playing with this library and love it very much so far, I'm using V2 but needed JSON for MVC so I wrote this subroutine as an addon.
getJSON: function (highlighted) {
// Control vars
var dataset = [];
var id = $(this).prop('id');
// Column and row length
var x = $.fn.jexcel.defaults[id].columns.length;
var y = $.fn.jexcel.defaults[id].data.length;
// Go through the columns to get the data
for (j = 0; j < y; j++) {
var data = new Object();
for (i = 0; i < x; i++) {
// Cell
cell = $(this).find('#' + i + '-' + j);
// Cell selected or fullset
if (!highlighted || $(cell).hasClass('highlight')) {
// Get value
colName = $.fn.jexcel.defaults[id].colHeaders[i];
colName = colName == undefined ? x : colName;
data[colName] = $(this).jexcel('getValue', $(cell));
}
}
dataset.push(data);
}
return JSON.stringify(dataset);
},
I have some issue. I want to get json with key and value. can anybody help?
This is now supported. Example:
https://jsfiddle.net/paulhodel/jv7sth0z/
Thanks :)