mirror of
https://github.com/gnh1201/welsonjs.git
synced 2025-05-14 13:41:05 +00:00
Update msoffice.js
This commit is contained in:
parent
79bc3fe593
commit
2b524dcb13
|
@ -109,14 +109,15 @@ FileTypes.Word = [
|
||||||
|
|
||||||
// EXAMPLE: new Office.Excel()
|
// EXAMPLE: new Office.Excel()
|
||||||
function Excel() {
|
function Excel() {
|
||||||
this.Application = CreateObject("Excel.Application");
|
this.application = CreateObject("Excel.Application");
|
||||||
this.Version = this.Application.Version;
|
this.Version = this.application.Version;
|
||||||
this.Application.Visible = true;
|
this.application.Visible = true;
|
||||||
|
|
||||||
console.info("Microsoft Excel Version:", this.Version);
|
console.info("Microsoft Excel Version:", this.Version);
|
||||||
|
|
||||||
this.CurrentWorkbook = null;
|
this.currentWorkbook = null;
|
||||||
this.CurrentWorksheet = null;
|
this.currentWorksheet = null;
|
||||||
|
this.range = null;
|
||||||
|
|
||||||
this.open = function(filename) {
|
this.open = function(filename) {
|
||||||
if (typeof filename !== "undefined") {
|
if (typeof filename !== "undefined") {
|
||||||
|
@ -126,14 +127,14 @@ function Excel() {
|
||||||
}
|
}
|
||||||
if (FILE.fileExists(filename)) {
|
if (FILE.fileExists(filename)) {
|
||||||
console.warn("Found the file:", filename);
|
console.warn("Found the file:", filename);
|
||||||
this.Application.Workbooks.Open(filename);
|
this.application.Workbooks.Open(filename);
|
||||||
this.CurrentWorkbook = this.Application.ActiveWorkbook;
|
this.currentWorkbook = this.application.ActiveWorkbook;
|
||||||
} else {
|
} else {
|
||||||
console.warn("File not exists!");
|
console.warn("File not exists!");
|
||||||
this.CurrentWorkbook = this.Application.Workbooks.Add();
|
this.currentWorkbook = this.application.Workbooks.Add();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
this.CurrentWorkbook = this.Application.Workbooks.Add();
|
this.currentWorkbook = this.application.Workbooks.Add();
|
||||||
}
|
}
|
||||||
this.selectWorksheet(1);
|
this.selectWorksheet(1);
|
||||||
|
|
||||||
|
@ -142,21 +143,21 @@ function Excel() {
|
||||||
|
|
||||||
this.close = function() {
|
this.close = function() {
|
||||||
try {
|
try {
|
||||||
this.CurrentWorksheet = null;
|
this.currentWorksheet = null;
|
||||||
this.CurrentWorkbook.Close();
|
this.currentWorkbook.Close();
|
||||||
this.CurrentWorkbook = null;
|
this.currentWorkbook = null;
|
||||||
this.Application.Quit();
|
this.application.Quit();
|
||||||
this.Application = null;
|
this.application = null;
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
this.CurrentWorksheet = null;
|
this.currentWorksheet = null;
|
||||||
this.CurrentWorkbook = null;
|
this.currentWorkbook = null;
|
||||||
this.Application = null;
|
this.application = null;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
this.saveAs = function(filename) {
|
this.saveAs = function(filename) {
|
||||||
try {
|
try {
|
||||||
this.CurrentWorkbook.saveAs(filename);
|
this.currentWorkbook.saveAs(filename);
|
||||||
return FILE.fileExists(filename);
|
return FILE.fileExists(filename);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.error("Could not save a file:", e.message);
|
console.error("Could not save a file:", e.message);
|
||||||
|
@ -166,16 +167,25 @@ function Excel() {
|
||||||
|
|
||||||
this.selectWorksheet = function(idx) {
|
this.selectWorksheet = function(idx) {
|
||||||
if (idx == 0) {
|
if (idx == 0) {
|
||||||
this.CurrentWorksheet = this.Application.ActiveSheet;
|
this.currentWorksheet = this.application.ActiveSheet;
|
||||||
} else {
|
} else {
|
||||||
this.CurrentWorksheet = this.CurrentWorkbook.Worksheets(idx);
|
this.currentWorksheet = this.currentWorkbook.Worksheets(idx);
|
||||||
}
|
}
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
this.setRange = function(range) {
|
||||||
|
this.range = range;
|
||||||
|
return this;
|
||||||
|
};
|
||||||
|
|
||||||
this.getCellByPosition = function(row, col) {
|
this.getCellByPosition = function(row, col) {
|
||||||
return new Excel.Cell(this.CurrentWorksheet.Cells(row, col));
|
if (this.range == null) {
|
||||||
|
return new Excel.Cell(this.currentWorksheet.Cells(row, col));
|
||||||
|
} else {
|
||||||
|
return new Excel.Cell(this.currentWorksheet.Range(this.range).Cells(row, col));
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
Excel.SupportedFileTypes = FileTypes.Excel;
|
Excel.SupportedFileTypes = FileTypes.Excel;
|
||||||
|
@ -202,13 +212,13 @@ Excel.Cell = function(cell) {
|
||||||
|
|
||||||
// EXAMPLE: new Office.PowerPoint()
|
// EXAMPLE: new Office.PowerPoint()
|
||||||
function PowerPoint() {
|
function PowerPoint() {
|
||||||
this.Application = CreateObject("PowerPoint.Application");
|
this.application = CreateObject("PowerPoint.Application");
|
||||||
}
|
}
|
||||||
PowerPoint.SupportedFileTypes = FileTypes.PowerPoint;
|
PowerPoint.SupportedFileTypes = FileTypes.PowerPoint;
|
||||||
|
|
||||||
// EXAMPLE: new Office.Word()
|
// EXAMPLE: new Office.Word()
|
||||||
function Word() {
|
function Word() {
|
||||||
this.Application = CreateObject("Word.Application");
|
this.application = CreateObject("Word.Application");
|
||||||
}
|
}
|
||||||
Word.SupportedFileTypes = FileTypes.Word;
|
Word.SupportedFileTypes = FileTypes.Word;
|
||||||
|
|
||||||
|
@ -216,7 +226,7 @@ exports.Excel = Excel;
|
||||||
exports.PowerPoint = PowerPoint;
|
exports.PowerPoint = PowerPoint;
|
||||||
exports.Word = Word;
|
exports.Word = Word;
|
||||||
|
|
||||||
exports.VERSIONINFO = "Microsoft Office interface (msoffice.js) version 0.1.4";
|
exports.VERSIONINFO = "Microsoft Office interface (msoffice.js) version 0.1.5";
|
||||||
exports.AUTHOR = "abuse@catswords.net";
|
exports.AUTHOR = "abuse@catswords.net";
|
||||||
exports.global = global;
|
exports.global = global;
|
||||||
exports.require = global.require;
|
exports.require = global.require;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user