Today, the boss gave me a demand, he needs to show the crawler crawling data on the page, because most of them are picture data, so my first reaction is to loop the spelling of the string
However, the data that the boss gave me is in the Excel table, so I need to convert the Excel table to a string. Find a lot of methods, are not appropriate, and finally found a NPM package called Excel-to-json package, now summarize.
First NPM Install Excel-to-json, then configure Package.json,
The Package.json is configured as follows
{ "name": "abc", "version": "0.0.0", " private": True, "scripts": { "start": "Node./bin/www" }, "dependencies": { "Xls-to-json": "*" }}
Create a new A.js file with the following code configuration:
NODE_XJ = require ("Xls-to-json"); Node_xj ({ "test.xlsx", "Output.json" function(err, result) { if (err) { console.error (err); Else { Console.log (result); }});
Since the table file is xlsx, the suffix is changed above, and the output JSON file is directly to the root directory.
Then use node to run the A.js file and finally get a JSON file successfully. Done
Note here: This package will only convert the data in the table header, which means that if there is no table in the table, he will not convert.
Once you get the JSON data, you can loop through the string and then successfully show it!
Excel-to-json (Show Excel table data to the page)