-
-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
62 additions
and
15 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
var STD = require("lib/std"); | ||
var SYS = require("lib/system"); | ||
var FILE = require("lib/file"); | ||
|
||
// msoffice.js | ||
|
@@ -119,12 +120,24 @@ function Excel() { | |
|
||
this.open = function(filename) { | ||
if (typeof filename !== "undefined") { | ||
Application.Workbooks.Open(filename); | ||
this.CurrentWorkbook = Application.ActiveWorkbook; | ||
// check type of the path | ||
if (filename.indexOf(":\\") < 0 && filename.indexOf(":/") < 0) { | ||
filename = SYS.getCurrentWorkingDirectory() + "\\" + filename; // get absolute path | ||
} | ||
if (FILE.fileExists(filename)) { | ||
console.warn("Found the file:", filename); | ||
this.Application.Workbooks.Open(filename); | ||
this.CurrentWorkbook = this.Application.ActiveWorkbook; | ||
} else { | ||
console.warn("File not exists!"); | ||
this.CurrentWorkbook = this.Application.Workbooks.Add(); | ||
} | ||
} else { | ||
this.CurrentWorkbook = this.Application.Workbooks.Add(); | ||
} | ||
this.selectWorksheet(1); | ||
|
||
return this; | ||
}; | ||
|
||
this.close = function() { | ||
|
@@ -157,14 +170,18 @@ function Excel() { | |
} else { | ||
this.CurrentWorksheet = this.CurrentWorkbook.Worksheets(idx); | ||
} | ||
|
||
return this; | ||
}; | ||
|
||
this.getValueByPosition = function(row, col) { | ||
return this.CurrentWorksheet.Cells(row, col).Value; | ||
}; | ||
|
||
this.setValueByPosition = function(row, col, value) { | ||
return this.CurrentWorksheet.Cells(row, col).Value = value; | ||
this.CurrentWorksheet.Cells(row, col).Value = value; | ||
|
||
return this; | ||
}; | ||
}; | ||
Excel.SupportedFileTypes = FileTypes.Excel; | ||
|
@@ -185,7 +202,7 @@ exports.Excel = Excel; | |
exports.PowerPoint = PowerPoint; | ||
exports.Word = Word; | ||
|
||
exports.VERSIONINFO = "Microsoft Office interface (msoffice.js) version 0.1.2"; | ||
exports.VERSIONINFO = "Microsoft Office interface (msoffice.js) version 0.1.3"; | ||
exports.AUTHOR = "[email protected]"; | ||
exports.global = global; | ||
exports.require = global.require; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,36 @@ | ||
// officeloader.js | ||
// Namhyeon Go <[email protected]> | ||
// https://github.com/gnh1201/welsonjs | ||
|
||
var SYS = require("lib/system"); | ||
var Office = require("lib/msoffice"); | ||
var ChatGPT = require("lib/chatgpt"); | ||
|
||
function main(args) { | ||
// 기존 파일을 여는 경우 인자에 파일 경로 추가 | ||
if (args.length > 0) { | ||
var filename = args[0]; | ||
open(filename); | ||
} else { | ||
test(); | ||
} | ||
} | ||
|
||
function open(filename) { | ||
// 엑셀 인스턴스 생성 | ||
var excel = new Office.Excel(); | ||
|
||
// 엑셀 열기 | ||
excel.open(filename); | ||
|
||
// .... 여기서 작업하세요 .... | ||
|
||
// 엑셀 닫기 | ||
//excel.close(); | ||
} | ||
|
||
function test() { | ||
// 엑셀 인스턴스 생성 | ||
var excel = new Office.Excel(); | ||
|
||
// 질문 목록 | ||
|
@@ -24,7 +53,8 @@ function main(args) { | |
i++; | ||
}); | ||
|
||
// 엑셀 닫기 | ||
//excel.close(); | ||
} | ||
|
||
exports.main = main; | ||
exports.main = main; |