mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-11-27 10:00:57 +00:00
Add Korea business area code checker example
Refactored korea_business_areacode.json to include metadata and expanded area code data. Added korea_biz_area_checker.js example script to read Excel files and match business numbers to area names using the updated area code data.
This commit is contained in:
parent
f86ea078c6
commit
d156e40e6b
|
|
@ -1,4 +1,9 @@
|
|||
{
|
||||
"title": "Korea Business Number Area Code",
|
||||
"author": "Namhyeon Go <gnh1201@catswords.re.kr>, WelsonJS OSS team",
|
||||
"website": "https://github.com/gnh1201/welsonjs",
|
||||
"created_on": "2025-11-19",
|
||||
"data": {
|
||||
"seoul": [
|
||||
100,
|
||||
101,
|
||||
|
|
@ -169,5 +174,58 @@
|
|||
],
|
||||
"jeju": [
|
||||
616
|
||||
],
|
||||
"p_seoul": [
|
||||
116,
|
||||
775
|
||||
],
|
||||
"p_incheon": [
|
||||
172,
|
||||
139
|
||||
],
|
||||
"p_gyeonggi": [
|
||||
696,
|
||||
276,
|
||||
585,
|
||||
133,
|
||||
687,
|
||||
509,
|
||||
581,
|
||||
557,
|
||||
405,
|
||||
727,
|
||||
514,
|
||||
371
|
||||
],
|
||||
"p_busan": [
|
||||
825,
|
||||
644,
|
||||
449
|
||||
],
|
||||
"p_daejeon": [
|
||||
306
|
||||
],
|
||||
"p_sejong": [
|
||||
330,
|
||||
698
|
||||
],
|
||||
"p_gwangju": [
|
||||
256
|
||||
],
|
||||
"p_gyeongbuk": [
|
||||
568
|
||||
],
|
||||
"p_chungnam": [
|
||||
709,
|
||||
294
|
||||
],
|
||||
"p_chungbuk": [
|
||||
203,
|
||||
136
|
||||
],
|
||||
"p_jeonbuk": [
|
||||
586,
|
||||
704
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
57
examples/korea_biz_area_checker.js
Normal file
57
examples/korea_biz_area_checker.js
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// korea_biz_area_checker.js
|
||||
// Namhyeon Go <gnh1201@catswords.re.kr>, WelsonJS OSS team
|
||||
// https://github.com/gnh1201/welsonjs
|
||||
//
|
||||
var FILE = require("lib/file");
|
||||
var Office = require("lib/msoffice");
|
||||
|
||||
function main(args) {
|
||||
// Business Area Code in Korea
|
||||
console.log("> Business Area Code in Korea");
|
||||
var data_biz_areacode = JSON.parse(FILE.readFile("data/korea_business_areacode.json")).data;
|
||||
console.log(JSON.stringify(data_biz_areacode));
|
||||
|
||||
// Open the Microsoft Excel file
|
||||
console.log("> Open the Microsoft Excel file");
|
||||
var excel = new Office.Excel();
|
||||
excel.open("data\\example.xlsx");
|
||||
|
||||
// Retrieve the business area code
|
||||
for (var i = 3; i < 1233; i++) {
|
||||
try {
|
||||
// check the biz area name
|
||||
console.log(">> check the biz area name");
|
||||
var areaname = excel.getCellByPosition(i, 16).getValue();
|
||||
if (!!areaname)
|
||||
continue;
|
||||
|
||||
// check the biz number
|
||||
console.log(">> check the biz number");
|
||||
var biznumber = excel.getCellByPosition(i, 8).getValue();
|
||||
if (!biznumber)
|
||||
continue;
|
||||
|
||||
// match the biznumber to biz area code data
|
||||
console.log(">> match the biznumber to biz area code data: " + biznumber);
|
||||
var matched_areaname = "unknown";
|
||||
for (var k in data_biz_areacode) {
|
||||
var areacode = parseInt(biznumber.substring(0, 3));
|
||||
if (data_biz_areacode[k].indexOf(areacode) > -1) {
|
||||
matched_areaname = k;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
console.log(">> write the matched area name: " + matched_areaname);
|
||||
excel.getCellByPosition(i, 16).setValue(matched_areaname);
|
||||
} catch (e) {
|
||||
excel.getCellByPosition(i, 16).setValue("unknown");
|
||||
}
|
||||
}
|
||||
|
||||
excel.saveAs("example_edited.xlsx");
|
||||
|
||||
excel.close();
|
||||
}
|
||||
|
||||
exports.main = main;
|
||||
Loading…
Reference in New Issue
Block a user