Skip to content

Try to handle the case where a <c> element is missing an r attribute #537

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 13, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion lib/doc/row.js
Original file line number Diff line number Diff line change
Expand Up @@ -329,13 +329,30 @@ Row.prototype = {
throw new Error('Invalid row number in model');
}
this._cells = [];
var previousAddress;
value.cells.forEach(cellModel => {
switch (cellModel.type) {
case Cell.Types.Merge:
// special case - don't add this types
break;
default:
var cell = this.getCellEx(colCache.decodeAddress(cellModel.address));
var address;
if (cellModel.address) {
address = colCache.decodeAddress(cellModel.address);
} else if (previousAddress) {
// This is a <c> element without an r attribute
// Assume that it's the cell for the next column
var row = previousAddress.row;
var col = previousAddress.col + 1;
address = {
row: row,
col: col,
address: colCache.encodeAddress(row, col),
$col$row: '$' + colCache.n2l(col) + '$' + row
};
}
previousAddress = address;
var cell = this.getCellEx(address);
cell.model = cellModel;
break;
}
Expand Down