jQuery get data from HTML file table or Excel file -
getting text of html file quite simple using jq .text() command follows:
$('#mytable tr:nth-child(1) td:nth-child(1)').text(); however, need able apply data separate file, rather table within page. far have not been able it.
the file has lot of data in it, don't want load file page.
i'm having file size issue when converting table excel format html. html file on 25mb, whereas excel file less 1mb.
it might, therefore, better have data in excel format file , there script, far have found difficult specifying line , column.
i'm sure quite simple thing try , really, can give advice.
a working example: http://jsfiddle.net/p9sbp/119/
this plausible way solve problem: first, convert data json, javascript can interact nicely. easiest way start open document in excel, go "save as" menu , choose comma separated values (.csv) type drop down list. there many possible ways convert csv json. perhaps easiest website this work you.
once in json format, javascript/jquery can read this:
function get_data() { var request = $.get("json_data_url.json", {}, use_data, "json"); request.fail(function (jqxhr, textstatus, errorthrown) { // on failure } } function use_data(result) { // example usage var first_row = result[0]; var second_row = result[1]; var first_row_data = result[0].field_name; var second_row_data = result[1]['field_name']; (var = 0; < result.length; i++) { // each row total_cost += parseint(result[i].cost, 10); } } note: javascript on client have download whole data file. if data file large enough want prevent this, need sort of end written in, example, php or asp find necessary data , return that.
Comments
Post a Comment