Comparing version 0.0.3 to 0.0.4
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -51,2 +51,13 @@ /** | ||
// return a sparse array of cell values | ||
get values() { | ||
var values = []; | ||
_.each(this._cells, function(cell) { | ||
if (cell.type != Enums.ValueType.Null) { | ||
values[cell.col] = cell.value; | ||
} | ||
}); | ||
return values; | ||
}, | ||
get dimensions() { | ||
@@ -53,0 +64,0 @@ var min = 0; |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ /** |
@@ -126,3 +126,3 @@ /** | ||
}, | ||
getRow: function(r) { | ||
_getRow: function(r) { | ||
var row = this._rows[r-1]; | ||
@@ -153,3 +153,3 @@ if (!row) { | ||
var row = this.getRow(cell.row); | ||
var row = this._getRow(cell.row); | ||
row.setCell(cell); | ||
@@ -164,5 +164,14 @@ | ||
if (value instanceof Array) { | ||
_.each(value, function(item, index) { | ||
self.getCell(row, index + 1).value = item; | ||
}); | ||
if (value[0] != undefined) { | ||
// contiguous array - start at column 1 | ||
var index = 1; | ||
_.each(value, function(item) { | ||
self.getCell(row, index++).value = item; | ||
}); | ||
} else { | ||
// sparse array - assign columns by index | ||
_.each(value, function(item, index) { | ||
self.getCell(row, index).value = item; | ||
}); | ||
} | ||
} else { | ||
@@ -177,2 +186,10 @@ // assume object with column keys | ||
}, | ||
getRow: function(number) { | ||
return this._getRow(number).values; | ||
}, | ||
eachRow: function(iteratee) { | ||
this._rows.forEach(function(row) { | ||
iteratee(row.number, row.values); | ||
}); | ||
}, | ||
mergeCells: function() { | ||
@@ -179,0 +196,0 @@ var dimensions = new Dimensions(Array.prototype.slice.call(arguments, 0)); // convert arguments into Array |
@@ -0,0 +0,0 @@ /** |
@@ -0,0 +0,0 @@ # Workbook Model |
{ | ||
"name": "exceljs", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Excel Workbook Manager", | ||
@@ -5,0 +5,0 @@ "private": false, |
@@ -45,9 +45,25 @@ # ExcelJS | ||
// Add a couple of Rows by key-value | ||
// Add a couple of Rows by key-value (after the last current row) | ||
sheet.addRow({id: 1, name: "John Doe", dob: new Date(1970,1,1)}); | ||
sheet.addRow({id: 2, name: "Jane Doe", dob: new Date(1965,1,7)}); | ||
// Add another row by Array | ||
// Add a row by contiguous Array (assign to columns A, B & C) | ||
sheet.addRow([3, "Sam", new Date()]); | ||
// Add a row by sparse Array (assign to columns A, E & I) | ||
var row = []; | ||
row[1] = 4; | ||
row[5] = "Kyle"; | ||
row[9] = new Date(); | ||
sheet.addRow(row); | ||
// get a row as a sparse array | ||
row = sheet.getRow(4); | ||
assert(row[5] == "Kyle"); | ||
// iterate over all rows (as sparse arrays) | ||
sheet.eachRow(function(number, row) { | ||
console.log("Row " + number + " = " + JSON.stringify(row)); | ||
}); | ||
// Modify individual cells | ||
@@ -68,2 +84,3 @@ sheet.getCell("C3").value = new Date(1968, 5, 1); | ||
assert(sheet.getCell("A4").value === sheet.getCell("B5")); | ||
``` | ||
@@ -73,14 +90,12 @@ | ||
| Name | Enum(*) | Description | Example Value | | ||
| --------- | --------- | ------------- | ------------- | | ||
| Null | 0 | No value. | null | | ||
| Merge | 1 | N/A | N/A | | ||
| Number | 2 | A numerical value | 3.14 | | ||
| String | 3 | A text value | "Hello, World!" | | ||
| Date | 4 | A Date value | new Date() | | ||
| Hyperlink | 5 | A hyperlink | { text: "www.mylink.com", hyperlink: "http://www.mylink.com" } | | ||
| Formula | 6 | A formula | { formula: "A1+A2", result: 7 } | | ||
| Enum Name | Enum(*) | Description | Example Value | | ||
| ------------------------- | --------- | ----------------- | ------------- | | ||
| Excel.ValueType.Null | 0 | No value. | null | | ||
| Excel.ValueType.Merge | 1 | N/A | N/A | | ||
| Excel.ValueType.Number | 2 | A numerical value | 3.14 | | ||
| Excel.ValueType.String | 3 | A text value | "Hello, World!" | | ||
| Excel.ValueType.Date | 4 | A Date value | new Date() | | ||
| Excel.ValueType.Hyperlink | 5 | A hyperlink | { text: "www.mylink.com", hyperlink: "http://www.mylink.com" } | | ||
| Excel.ValueType.Formula | 6 | A formula | { formula: "A1+A2", result: 7 } | | ||
(*) Enum values can be accessed via Excel.ValueType | ||
## Reading XLSX | ||
@@ -87,0 +102,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
110116
2511
128