Showing
1 changed file
with
60 additions
and
27 deletions
| 1 | -// @breif xlsx 모듈추출 | ||
| 2 | - | ||
| 3 | const xlsx = require( "xlsx" ); | 1 | const xlsx = require( "xlsx" ); |
| 4 | - | 2 | +// 엑셀 파일을 가져오기 |
| 5 | -// @files 엑셀 파일을 가져온다. | 3 | + |
| 6 | - | 4 | +const excelFile = xlsx.readFile( "컴퓨터공학과 권장이수 가이드라인.xlsx"); |
| 7 | -const excelFile = xlsx.readFile( "컴퓨터공학과 권장이수 가이드라인.xlsx" ); | 5 | +// 엑셀 파일의 첫번째 시트의 정보 추출 |
| 8 | -// @breif 엑셀 파일의 첫번째 시트의 정보를 추출 | 6 | + |
| 9 | - | 7 | +const sheetName = excelFile.SheetNames[0]; |
| 10 | -const sheetName = excelFile.SheetNames[0]; // @details 첫번째 시트 정보 추출 | 8 | +const firstSheet = excelFile.Sheets[sheetName]; |
| 11 | -const firstSheet = excelFile.Sheets[sheetName]; // @details 시트의 제목 추출 | 9 | +const jsonData = xlsx.utils.sheet_to_json(firstSheet); |
| 12 | - | 10 | + |
| 13 | -// @details 엑셀 파일의 첫번째 시트를 읽어온다. | 11 | +var first_first = []; |
| 14 | - | 12 | +var first_second = []; |
| 15 | -const jsonData = xlsx.utils.sheet_to_json( firstSheet, { defval : "" } ); | 13 | +var second_first = []; |
| 16 | -console.log( jsonData ); | 14 | +var second_second = []; |
| 17 | - | 15 | +var third_first = []; |
| 18 | -var ary = []; | 16 | +var third_second = []; |
| 19 | - | 17 | +var fourth_first = []; |
| 20 | -const xlsxFile = require('read-excel-file/node'); xlsxFile('컴퓨터공학과 권장이수 가이드라인.xlsx').then((rows) => { | 18 | +var fourth_second = []; |
| 21 | - //console.log(rows); console.table(rows); | 19 | + |
| 22 | - for (var i in rows) { | 20 | +function jason_to_arry() { |
| 23 | - ary.push(rows[i]); | 21 | + for (var data in jsonData){ |
| 24 | - | 22 | + first_first.push(jsonData[data]['1학년 1학기']); |
| 25 | - | 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학기']); | ||
| 26 | } | 30 | } |
| 27 | - //console.log(ary) | ||
| 28 | - }) | ||
| 29 | -console.log(ary); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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() | ... | ... |
-
Please register or login to post a comment