2020-07-27 08:14:39 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////////////
|
2020-11-09 10:06:34 +00:00
|
|
|
// Microsoft Excel API
|
2020-07-27 08:14:39 +00:00
|
|
|
/////////////////////////////////////////////////////////////////////////////////
|
|
|
|
var FILE = require("lib/file");
|
|
|
|
|
|
|
|
exports.createExcelFile = function(filename) {
|
|
|
|
var success = false;
|
|
|
|
|
|
|
|
try {
|
|
|
|
var objExcel = CreateObject("Excel.Application");
|
|
|
|
objExcel.visible = true;
|
|
|
|
|
|
|
|
var objWorkbook = objExcel.workbooks.add();
|
|
|
|
|
2020-11-04 07:30:52 +00:00
|
|
|
if (!FILE.fileExists(filename)) {
|
2020-07-27 08:14:39 +00:00
|
|
|
objWorkbook.saveAs(filename);
|
|
|
|
success = FILE.fileExists(filename);
|
|
|
|
}
|
|
|
|
|
|
|
|
objWorkbook.close();
|
|
|
|
objExcel.quit();
|
2020-11-04 07:30:52 +00:00
|
|
|
} catch (e) {}
|
2020-07-27 08:14:39 +00:00
|
|
|
|
|
|
|
return success;
|
|
|
|
};
|
|
|
|
|
|
|
|
exports.openExcelFile = function(filename, callback) {
|
|
|
|
var success = false;
|
|
|
|
|
2020-11-04 07:30:52 +00:00
|
|
|
if (FILE.fileExists(filename)) {
|
2020-07-27 08:14:39 +00:00
|
|
|
try {
|
|
|
|
var objExcel = CreateObject("Excel.Application");
|
|
|
|
objExcel.visible = true;
|
|
|
|
var objWorkbook = objExcel.workbooks.open(filename);
|
|
|
|
|
|
|
|
if (typeof(callback) !== "undefined") {
|
|
|
|
success = callback(objWorkbook);
|
|
|
|
} else {
|
|
|
|
success = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
objWorkbook.close();
|
|
|
|
objExcel.quit();
|
2020-11-04 07:30:52 +00:00
|
|
|
} catch (e) {}
|
2020-07-27 08:14:39 +00:00
|
|
|
}
|
2020-11-04 07:30:52 +00:00
|
|
|
|
2020-07-27 08:14:39 +00:00
|
|
|
return success;
|
|
|
|
};
|