forked from exceljs/exceljs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of git://github.com/p3rio/exceljs into p3rio-ma…
…ster
- Loading branch information
Showing
17 changed files
with
433 additions
and
120 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,56 @@ | ||
/** | ||
* Copyright (c) 2018 Paweł Siemienik | ||
* LICENCE: MIT - please refer to LICENCE file included with this module | ||
* or https://github.com/guyonroche/exceljs/blob/master/LICENSE | ||
*/ | ||
|
||
'use strict'; | ||
|
||
var Anchor = module.exports = function (model = {}) { | ||
this.nativeCol = model.nativeCol || 0; | ||
this.nativeColOff = model.nativeColOff || 0; | ||
this.nativeRow = model.nativeRow || 0; | ||
this.nativeRowOff = model.nativeRowOff || 0; | ||
|
||
if (model.col) { | ||
this.col = model.col; | ||
} | ||
|
||
if (model.row) { | ||
this.row = model.row; | ||
} | ||
}; | ||
|
||
Anchor.asInstance = function (model) { | ||
return model instanceof Anchor || model == null ? model : new Anchor(model); | ||
}; | ||
|
||
Anchor.prototype = { | ||
worksheet: null, | ||
get col() { | ||
return this.nativeCol + Math.min(this.colWidth - 1, this.nativeColOff) / this.colWidth; | ||
}, | ||
set col(v) { | ||
if (v === this.col) return; | ||
this.nativeCol = Math.floor(v); | ||
this.nativeColOff = Math.floor((v - this.nativeCol) * this.colWidth); | ||
}, | ||
get row() { | ||
return this.nativeRow + Math.min(this.rowHeight - 1, this.nativeRowOff) / this.rowHeight; | ||
}, | ||
set row(v) { | ||
if (v === this.row) return; | ||
this.nativeRow = Math.floor(v); | ||
this.nativeRowOff = Math.floor((v - this.nativeRow) * this.rowHeight); | ||
}, | ||
get colWidth() { | ||
return this.worksheet && this.worksheet.getColumn(this.nativeCol + 1) && this.worksheet.getColumn(this.nativeCol + 1).isCustomWidth ? | ||
Math.floor(this.worksheet.getColumn(this.nativeCol + 1).width * 10000) : | ||
640000; | ||
}, | ||
get rowHeight() { | ||
return this.worksheet && this.worksheet.getRow(this.nativeRow + 1) && this.worksheet.getRow(this.nativeRow + 1).height ? | ||
Math.floor(this.worksheet.getRow(this.nativeRow + 1).height * 10000) : | ||
180000; | ||
} | ||
}; |
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
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
Binary file not shown.
Oops, something went wrong.