getData will return the formulas applied to cells instead of the value in the table.
var data = $('#my').jexcel('getData');
Please guide me how to getData from the table the actual cell values instead of the formulas.
I think there is no built-in way to do it.
Only solution that I've found is from #225:
$('yourtable').find('#0-0').text(); // for Colum A1
Yes, this is the only way to get the parsed values.
Here's one way to retrieve:
let _cells = [];
let ddd = [];
let dd = $('yourtable').find('tr').map(function () {
let tds = $('yourtable').find('td').map(function () {
return $(this).text();
});
ddd.push(tds)
return tds;
});
_cells.push(dd);
// Compare the two.
console.log(_cells, $('yourtable').jexcel('getData'));
That's ^ untested but you get the idea.
This didn't work for me. I had to get the values by using the data-x and data-y attributes of the table cell.
Here's a function to return a cell reference (e.g. A1) as x, y co-ordinate:
var xy = cellref(mycell).split(",");
value = $('td[data-x="' + xy[0] + '"][data-y="' + xy[1] + '"]').html();
function cellref(thisCell) {
var x = thisCell.replace(/[^A-Za-z]/g, "");
x = x.charCodeAt(0) - 65;
var y = thisCell.replace(/\D/g, "");
y = y - 1;
return x + "," + y;
}
You can use the initial option
copyCompatibility: true
This means the copy and export will take into consideration the results, not formulas. Only valid for v3.
This didn't work for me. I had to get the values by using the data-x and data-y attributes of the table cell.
Here's a function to return a cell reference (e.g. A1) as x, y co-ordinate:
var xy = cellref(mycell).split(","); value = $('td[data-x="' + xy[0] + '"][data-y="' + xy[1] + '"]').html(); function cellref(thisCell) { var x = thisCell.replace(/[^A-Za-z]/g, ""); x = x.charCodeAt(0) - 65; var y = thisCell.replace(/\D/g, ""); y = y - 1; return x + "," + y; }
This is very useful
Using copyCompatibility: true you will get the values not formulas.