officegen
This is an addition to Ziv-Barber's officegen (here) to provide a reasonable way to add line breaks to table cells.
Contents:
Features:
- In addition to all features in source reop (Ziv-Barber's):
- Set table cell value as an array of objects.
Public API:
Word:
To add a table:
var table = [
[{
val: "No.",
opts: {
cellColWidth: 4261,
b:true,
sz: '48',
shd: {
fill: "7F7F7F",
themeFill: "text1",
"themeFillTint": "80"
},
fontFamily: "Avenir Book"
}
},{
val: "Title1",
opts: {
b:true,
color: "A00000",
align: "right",
shd: {
fill: "92CDDC",
themeFill: "text1",
"themeFillTint": "80"
}
}
},{
val: "Title2",
opts: {
align: "center",
vAlign: "center",
cellColWidth: 42,
b:true,
sz: '48',
shd: {
fill: "92CDDC",
themeFill: "text1",
"themeFillTint": "80"
}
}
}],
[1,[{"w:t":'All grown-ups were'},{"w:br":""},{"w:t":'once children'}],''],
[2,'there is no harm in putting off a piece of work until another day.',''],
[3,'But when it is a matter of baobabs, that always means a catastrophe.',''],
[4,'watch out for the baobabs!','END'],
]
var tableStyle = {
tableColWidth: 4261,
tableSize: 24,
tableColor: "ada",
tableAlign: "left",
tableFontFamily: "Comic Sans MS",
borders: true
}
docx.createTable (table, tableStyle);
License:
(The MIT License)
Copyright (c) 2013-2017 Ziv Barber;
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
'Software'), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Credit:
Donations:
The original author is accepting tips through Gittip