I'm working on a table that can export data to excel using js excel generator. It work somehow, my problem is I cant display all the data, it only display the current data shown.
hope you help me.
thanks.
$("#toExcel").click(function () {
var filename = $('title').text();
excel = new ExcelGen({
"src_id": "excelGen_table",
"show_header": true
});
excel.generate();
});
Related
I'm using sheetJS to convert HTML table into excel. The table was generated using datatable jquery with pagination. The data is from sql database, When im exporting it to excel, it only generates the page that is active in DOM.
my script to generate excel from html table:
let tbl1 = document.getElementById("Table1");
let worksheet_tmp1 = XLSX.utils.table_to_sheet(tbl1);
let a = XLSX.utils.sheet_to_json(worksheet_tmp1, { header: 1 })
let worksheet = XLSX.utils.json_to_sheet(a, { skipHeader: true })
const new_workbook = XLSX.utils.book_new()
XLSX.utils.book_append_sheet(new_workbook, worksheet, "worksheet")
XLSX.writeFile(new_workbook, 'Report.xls')
How can i include the whole data not only just the active page? Thanks for answer
I have an excel file where data changes every second and I want to read that data every second and update it in the web. I am thinking of creating a table and update it dynamically.
I am currently using xlsx node package to read the excel data.
//something like this, taken from stack itself
var XLSX = require('xlsx')
var workbook = XLSX.readFile('test.xlsx');
var sheet_name_list = workbook.SheetNames;
var xlData = XLSX.utils.sheet_to_json(workbook.Sheets[sheet_name_list[0]]);
console.log(xlData);
But once the values are changed it is not updated accordingly. I want the code read the changed values, so that I can update them in the web table.
I am using angularjs and exporting data in excel from the table that has been uploaded.
I am using the following code:
function (e)
{
window.open('data:application/vnd.ms-excel,' + encodeURIComponent($('div[id$=exportable]').html()));
e.preventDefault();
It is allowing me to download the file but extension is missing. Can you pls guide me how to change file name and extension both for the same?
Thanks
Excel to JSON
This is basically what you are looking for, some way to turn excel to JSON data with JavaScript. Here is a link to an article about how it can be done using XLSXReader in a web app along with AngularJS.
Sample Code
$(function() {
$("#xlsxFile").change(function(event) {
var file = this.files[0],
sheets;
XLSXReader(file, true, function(xlsxData) {
sheets = xlsxData.sheets;
// Do somehting with sheets. It's a
// Javascript object with sheet names
// as keys and data as value in form of 2D array
});
});
});
Working Example
Here is a working example of the code. You can upload a csv file and have it turned into JSON.
I hope this helps.
I am new to JavaScript and D3 and cannot figure out how to allow users to upload a csv file and displaying a scatterplot using d3. I am using the tag to allow user to select file. But I am not sure on what the next step should be. Is there a way to read the csv file and store it's contents in a d3 array and then displaying a graph using that array ??
Thanks in advance
Look into the d3.csv function (https://github.com/mbostock/d3/wiki/CSV). Here is a simple example
//load up the example.csv file
d3.csv('example.csv',
function(data){
//this is an object, the contents of which should
//match your example.csv input file.
console.log(data);
// do more stuff with 'data' related to
// drawing the scatterplots.
//
//-----------------------
},
function(error, rows) {
console.log(rows);
};
);
There are a number of examples online showing you how to go from a data array to a scatterplot...it's a matter of modifying those examples to fit your specific data format.
I need to extract the data from an excel sheet into csv or json format and then display the content in the form of charts(bar, pie and line) using javascript. I have been working on it since 2 days and not able to find any good source. Any help regarding this would be appreciated. Thank you.
You can also pull data from a google spreadsheet as CSV data like this:
var spreadsheet = "https://docs.google.com/spreadsheet/pub?key=youruniquekeyhere&single=true&gid=2&output=csv"
d3.csv(spreadsheet, function (error, data) {
// use your data here
});
Notice the output=csv at the end of that URL.
gid=0 is worksheet 1, gid=1 is worksheet 2 and so on. You must publish your worksheet to the web first to make it available.
In addition to Christophe Viau's tutorials, here are more resources:
https://github.com/mbostock/d3/wiki/Gallery#basic-charts
http://www.d3noob.org