{"id":8987,"date":"2020-03-03T18:14:40","date_gmt":"2020-03-03T09:14:40","guid":{"rendered":"http:\/\/www.gisdeveloper.co.kr\/?p=8987"},"modified":"2020-05-28T09:40:43","modified_gmt":"2020-05-28T00:40:43","slug":"javascript%eb%a1%9c-excel-%ed%8c%8c%ec%9d%bc-%ec%9d%bd%ea%b8%b0","status":"publish","type":"post","link":"http:\/\/www.gisdeveloper.co.kr\/?p=8987","title":{"rendered":"JavaScript\ub85c Excel \ud30c\uc77c \uc77d\uae30"},"content":{"rendered":"<p>\uc11c\ubc84\uce21\uc758 \uae30\uc220\uc5c6\uc774 \ud074\ub77c\uc774\uc5b8\ud2b8 \uae30\uc220\ub9cc\uc73c\ub85c \ub85c\uceec\uc5d0 \uc800\uc7a5\ub41c \uc5d1\uc140 \ud30c\uc77c\uc744 \ub2e4\ub8f0 \uc218 \uc788\ub294 \ub77c\uc774\ube0c\ub7ec\ub9ac\uc778 <a href='https:\/\/github.com\/SheetJS\/sheetjs'>sheetjs<\/a>\uc5d0 \ub300\ud55c \ub2e4\uc591\ud55c \uae30\ub2a5 \uc911 \uc5d1\uc140 \ud30c\uc77c\uc744 \uc77d\ub294 \uae30\ub2a5\uc5d0 \ub300\ud55c JavaScript \ucf54\ub4dc\ub97c \uc815\ub9ac\ud574 \ubd05\ub2c8\ub2e4.<\/p>\n<p>\uc774 \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ubcc4\ub3c4\ub85c \ub2e4\uc6b4\ub85c\ub4dc \ubc1b\uc9c0 \uc54a\uace0\ub3c4 CDN\uc744 \ud1b5\ud574 \uc774\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc544\ub798\ub294 \uc81c\uac00 \uc774\uc6a9\ud55c CDN \uc811\uadfc\uc785\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">\r\n<script src=\"https:\/\/cdnjs.cloudflare.com\/ajax\/libs\/xlsx\/0.15.5\/xlsx.full.min.js\"><\/script>\r\n<\/pre>\n<p>\uc77d\uace0\uc790 \ud558\ub294 \uc5d1\uc140 \ud30c\uc77c\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"http:\/\/www.gisdeveloper.co.kr\/wp-content\/uploads\/2020\/03\/excel.png\" alt=\"\" width=\"684\" height=\"372\" class=\"aligncenter size-full wp-image-8991\" \/><\/p>\n<p>\uc704\uc758 \uc5d1\uc140 \ud30c\uc77c\uc744 \uc120\ud0dd\ud558\uace0, \uc120\ud0dd\ub41c \uc5d1\uc140 \ud30c\uc77c\uc744 JSON \ud615\uc2dd\uc73c\ub85c \ubcc0\ud658\ud574 \ucf58\uc194\uc5d0 \ucd9c\ub825\ud558\ub294 DOM \uc694\uc18c\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"html\">\r\n<input type=\"file\" onchange=\"readExcel()\" \/>\r\n<\/pre>\n<p>\uc704\uc758 input DOM \uc694\uc18c\ub97c \ud1b5\ud574 \ud30c\uc77c\uc744 \uc120\ud0dd\ud560 \ub54c \ubc1c\uc0dd\ud558\ub294 \uc774\ubca4\ud2b8 \ucf54\ub4dc\ub294 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"js\">\r\nfunction readExcel() {\r\n    let input = event.target;\r\n    let reader = new FileReader();\r\n\r\n    reader.onload = function () {\r\n        let data = reader.result;\r\n        let workBook = XLSX.read(data, { type: 'binary' });\r\n\r\n        workBook.SheetNames.forEach(function (sheetName) {\r\n            console.log('SheetName: ' + sheetName);\r\n\r\n            let rows = XLSX.utils.sheet_to_json(workBook.Sheets[sheetName]);\r\n            console.log(JSON.stringify(rows));\r\n        })\r\n    };\r\n\r\n    reader.readAsBinaryString(input.files[0]);\r\n}\r\n<\/pre>\n<p>\uc2e4\ud589\ud558\uace0, \uc5d1\uc140 \ud30c\uc77c\uc744 \uc120\ud0dd\ud574 \ubcf4\uba74 \ub2e4\uc74c\uacfc \uac19\uc740 \ub0b4\uc6a9\uc774 \ucf58\uc194\uc5d0 \ud45c\uc2dc\ub418\ub294 \uac83\uc744 \ud655\uc778\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4.<\/p>\n<pre class=\"EnlighterJSRAW\" data-enlighter-language=\"json\">\r\nSheetName: #\uc778\uad6c\uc218\r\n[\r\n   {\r\n      \"\uc9c0\uc5ed\uba85\":\"\ubb34\uc548\uad70 \ubb34\uc548\uc74d\",\r\n      \"\ub0a8\uc790\":8599,\r\n      \"\uc5ec\uc790\":7900,\r\n      \"\uac00\uad6c\uc218\":6968,\r\n      \"\ub178\uc778\uc218\":732,\r\n      \"\uc544\uc800\uc528\":1359,\r\n      \"\uc5b4\ub9b0\uc774\":4627\r\n   },\r\n   {\r\n      \"\uc9c0\uc5ed\uba85\":\"\ubb34\uc548\uad70 \uc77c\ub85c\uc74d\",\r\n      \"\ub0a8\uc790\":3659,\r\n      \"\uc5ec\uc790\":3243,\r\n      \"\uac00\uad6c\uc218\":3526,\r\n      \"\ub178\uc778\uc218\":8711,\r\n      \"\uc544\uc800\uc528\":8758,\r\n      \"\uc5b4\ub9b0\uc774\":4099\r\n   },\r\n\r\n   ....\r\n\r\n   {\r\n      \"\uc9c0\uc5ed\uba85\":\"\ubb34\uc548\uad70 \uc6b4\ub0a8\uba74\",\r\n      \"\ub0a8\uc790\":7357,\r\n      \"\uc5ec\uc790\":7667,\r\n      \"\uac00\uad6c\uc218\":3624,\r\n      \"\ub178\uc778\uc218\":8110,\r\n      \"\uc544\uc800\uc528\":8042,\r\n      \"\uc5b4\ub9b0\uc774\":9618\r\n   }\r\n]\r\n<\/pre>\n<p>sheetjs \ub77c\uc774\ube0c\ub7ec\ub9ac\ub294 \uc5d1\uc140\uc744 \uc77d\ub294 \uae30\ub2a5 \ubfd0\ub9cc \uc544\ub2c8\ub77c \uc0dd\uc131\ub3c4 \uac00\ub2a5\ud558\uba70 \uc815\uad50\ud55c \ucc98\ub9ac\uac00 \uac00\ub2a5\ud569\ub2c8\ub2e4.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\uc11c\ubc84\uce21\uc758 \uae30\uc220\uc5c6\uc774 \ud074\ub77c\uc774\uc5b8\ud2b8 \uae30\uc220\ub9cc\uc73c\ub85c \ub85c\uceec\uc5d0 \uc800\uc7a5\ub41c \uc5d1\uc140 \ud30c\uc77c\uc744 \ub2e4\ub8f0 \uc218 \uc788\ub294 \ub77c\uc774\ube0c\ub7ec\ub9ac\uc778 sheetjs\uc5d0 \ub300\ud55c \ub2e4\uc591\ud55c \uae30\ub2a5 \uc911 \uc5d1\uc140 \ud30c\uc77c\uc744 \uc77d\ub294 \uae30\ub2a5\uc5d0 \ub300\ud55c JavaScript \ucf54\ub4dc\ub97c \uc815\ub9ac\ud574 \ubd05\ub2c8\ub2e4. \uc774 \ub77c\uc774\ube0c\ub7ec\ub9ac\ub97c \ubcc4\ub3c4\ub85c \ub2e4\uc6b4\ub85c\ub4dc \ubc1b\uc9c0 \uc54a\uace0\ub3c4 CDN\uc744 \ud1b5\ud574 \uc774\uc6a9\ud560 \uc218 \uc788\uc2b5\ub2c8\ub2e4. \uc544\ub798\ub294 \uc81c\uac00 \uc774\uc6a9\ud55c CDN \uc811\uadfc\uc785\ub2c8\ub2e4. \uc77d\uace0\uc790 \ud558\ub294 \uc5d1\uc140 \ud30c\uc77c\uc740 \ub2e4\uc74c\uacfc \uac19\uc2b5\ub2c8\ub2e4. \uc704\uc758 \uc5d1\uc140 \ud30c\uc77c\uc744 \uc120\ud0dd\ud558\uace0, \uc120\ud0dd\ub41c \uc5d1\uc140 \ud30c\uc77c\uc744 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"http:\/\/www.gisdeveloper.co.kr\/?p=8987\" class=\"more-link\">\ub354 \ubcf4\uae30<span class=\"screen-reader-text\"> &#8220;JavaScript\ub85c Excel \ud30c\uc77c \uc77d\uae30&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[88,12],"tags":[],"class_list":["post-8987","post","type-post","status-publish","format-standard","hentry","category-javascript","category-opensource"],"_links":{"self":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8987","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8987"}],"version-history":[{"count":12,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8987\/revisions"}],"predecessor-version":[{"id":9334,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=\/wp\/v2\/posts\/8987\/revisions\/9334"}],"wp:attachment":[{"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8987"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8987"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.gisdeveloper.co.kr\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8987"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}