0

I've been looking for a way to export my data from MySQL into Ms.Excel format but to no avail.

I've tried using react-export-excel, but I can't get it to work even if I follow the documentation.

Assuming I haven't installed any packages, what are the packages do I need to do such a task ?

Thanks in advance

*p.s: sorry for the bad English

1 Answers1

0

To export data from MySQL, you can use the following package -

npm install mysql

Here is a snippets that can help you to get data from MySQL.

const mysql = require('mysql');

const connection = mysql.createPool({
  host     : 'localhost',
  user     : 'me',
  password : 'secret',
  database : 'my_db'
});

After getting data, you can use xlsx package

npm install xlsx

More documentation about mysql and xlsx can be found from npm repository.

https://www.npmjs.com/package/xlsx

https://www.npmjs.com/package/mysql

Shaharia Azam
  • 1,955
  • 19
  • 24
  • I've also tried using xlsx before, but it says 'cannot resolve fs module' or something like that. I'll dig deeper in their documentation though, thank you – nevwizurai Feb 11 '20 at 09:49
  • @nevwizurai you can take a look into https://stackoverflow.com/a/48359480/1431786 for `cannot resolve fs module` error. – Shaharia Azam Feb 11 '20 at 10:03
  • sorry but I still unable to get it to work. CMIIW but I don't think i can use the tutorial for ReactJS into React Native – nevwizurai Feb 13 '20 at 04:03