곽병민

Update excelread.js

1 -// @breif xlsx 모듈추출
2 -
3 const xlsx = require( "xlsx" ); 1 const xlsx = require( "xlsx" );
4 -
5 -// @files 엑셀 파일을 가져온다.
6 -
7 -const excelFile = xlsx.readFile( "컴퓨터공학과 권장이수 가이드라인.xlsx" );
8 -// @breif 엑셀 파일의 첫번째 시트의 정보를 추출
9 -
10 -const sheetName = excelFile.SheetNames[0]; // @details 첫번째 시트 정보 추출
11 -const firstSheet = excelFile.Sheets[sheetName]; // @details 시트의 제목 추출
12 -
13 -// @details 엑셀 파일의 첫번째 시트를 읽어온다.
14 -
15 -const jsonData = xlsx.utils.sheet_to_json( firstSheet, { defval : "" } );
16 -console.log( jsonData );
17 -
18 -var ary = [];
19 -
20 -const xlsxFile = require('read-excel-file/node'); xlsxFile('컴퓨터공학과 권장이수 가이드라인.xlsx').then((rows) => {
21 - //console.log(rows); console.table(rows);
22 - for (var i in rows) {
23 - ary.push(rows[i]);
24 -
25 -
26 - }
27 - //console.log(ary)
28 - })
29 -console.log(ary);
...\ No newline at end of file ...\ No newline at end of file
2 +// 엑셀 파일을 가져오기
3 +
4 +const excelFile = xlsx.readFile( "컴퓨터공학과 권장이수 가이드라인.xlsx");
5 +// 엑셀 파일의 첫번째 시트의 정보 추출
6 +
7 +const sheetName = excelFile.SheetNames[0];
8 +const firstSheet = excelFile.Sheets[sheetName];
9 +const jsonData = xlsx.utils.sheet_to_json(firstSheet);
10 +
11 +var first_first = [];
12 +var first_second = [];
13 +var second_first = [];
14 +var second_second = [];
15 +var third_first = [];
16 +var third_second = [];
17 +var fourth_first = [];
18 +var fourth_second = [];
19 +
20 +function jason_to_arry() {
21 + for (var data in jsonData){
22 + first_first.push(jsonData[data]['1학년 1학기']);
23 + first_second.push(jsonData[data]['1학년 2학기']);
24 + second_first.push(jsonData[data]['2학년 1학기']);
25 + second_second.push(jsonData[data]['2학년 2학기']);
26 + third_first.push(jsonData[data]['3학년 1학기']);
27 + third_second.push(jsonData[data]['3학년 2학기']);
28 + fourth_first.push(jsonData[data]['4학년 1학기']);
29 + fourth_second.push(jsonData[data]['4학년 2학기']);
30 + }
31 +}
32 +// jason -> array로 변경
33 +function remove_null() {
34 +first_first = first_first.filter(function(item) {
35 + return item !== null && item !== undefined && item !== '';
36 +});
37 +first_second = first_second.filter(function(item) {
38 + return item !== null && item !== undefined && item !== '';
39 + });
40 +second_first = second_first.filter(function(item) {
41 + return item !== null && item !== undefined && item !== '';
42 +});
43 +second_second = second_second.filter(function(item) {
44 + return item !== null && item !== undefined && item !== '';
45 + });
46 +third_first = third_first.filter(function(item) {
47 + return item !== null && item !== undefined && item !== '';
48 + });
49 +third_second = third_second.filter(function(item) {
50 + return item !== null && item !== undefined && item !== '';
51 + });
52 +fourth_first = fourth_first.filter(function(item) {
53 + return item !== null && item !== undefined && item !== '';
54 + });
55 +fourth_second = fourth_second.filter(function(item) {
56 + return item !== null && item !== undefined && item !== '';
57 + });
58 +}
59 +// null 값 제거
60 +
61 +jason_to_arry()
62 +remove_null()
......