PiedTeam / DreameCloneTraining-BE-Project

0 stars 0 forks source link

BE00: Research read file excel #11

Closed nnh53 closed 7 months ago

nnh53 commented 8 months ago
lcaohoanq commented 8 months ago

We choose this library for handling: https://www.npmjs.com/package/xlsx

lcaohoanq commented 8 months ago

I'm using these code to read the sample excel file, reference from the document above

import XLSX from "xlsx";

const xlsxPath = "../Employee-Sample-Data.xlsx";

const workbook = XLSX.readFile(xlsxPath);
const worksheet = workbook.Sheets["Data"];

const REGEX_ID = /^Ed\{5}$/gi;

const arrEmployee = XLSX.utils.sheet_to_json(worksheet);

console.log(`Total record: ${arrEmployee.length}`);

// console.log(arrEmployee);

// arrEmployee.forEach((employee) => {
//   if (!employee.EEID.match(REGEX_ID)) {
//     console.log(employee);
//   }
// });

for (const employee of arrEmployee) {
  console.log(employee);
}
lcaohoanq commented 8 months ago

My implement here:

https://github.com/lcaohoanq/js-excel-handling

lcaohoanq commented 8 months ago

im done, need turn to review @nnh53

nnh53 commented 8 months ago

send me a message to meeting with me @lcaohoanq, and demo for your BE mate @huy1707developer