调用ppt.write()
似乎修改了具有变量 colspan 的表,以便后续ppt.writeFile()
调用在表中插入无关的表单元格。下面的示例代码。
我认为这是一个错误(我已经提交了一个问题https://github.com/gitbrent/PptxGenJS/issues/911),但我想我会在这里问,以防我遗漏了什么。如果其他人遇到过这种情况并知道一种解决方法,我们将不胜感激。
let ppt = new PptxGenJS();
let slide = ppt.addSlide();
slide.addTable([
[
{ text: '1', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
{ text: '2', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
{ text: '3', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }}
],
[
{ text: '4', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
{ text: '5', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
{ text: '6', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
{ text: '7', options: { colspan: 3, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }}
],
[
{ text: '8', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
{ text: '9', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }},
{ text: '0', options: { colspan: 4, color: 'FFFFFF', fill: '000000', border: { pt: 1, color: 'FFFFFF' } }}
]
]);
ppt.writeFile('expected');
ppt.write('base64').then(data => { ppt.writeFile('bugged1'); });
ppt.write('base64'); ppt.writeFile('bugged2');