PptxGenJS icon indicating copy to clipboard operation
PptxGenJS copied to clipboard

Border is a string instead of a number in `demo_tables.mjs`

Open hesi726 opened this issue 1 year ago • 3 comments

genSlide02 function in demo_tables.mjs

       // BTM-LEFT
	let tabOpts3 = {
		x: 0.5,
		y: 5.15,
		w: 6.0,
		h: 2,
		margin: 0.05,
		align: "center",
		valign: "middle",
		fontSize: 16,
		border: { pt: "2", color: pptx.colors.TEXT2 },
		fill: { color: "F1F1F1" },
	};
	let arrTabRows3 = [
		[
			{ text: "A1\nA2\nA3", options: { rowspan: 3, fill: { color: pptx.colors.ACCENT6 } } },
			{ text: "B1\nB2", options: { rowspan: 2, fill: { color: pptx.colors.ACCENT2 } } },
			{ text: "C1", options: { fill: { color: pptx.colors.ACCENT4 } } },
		],
		[{ text: "C2", options: { fill: { color: pptx.colors.ACCENT4 } } }],
		[{ text: "B3 -> C3", options: { colspan: 2, fill: { color: pptx.colors.ACCENT5 } } }],
	];
	slide.addTable(arrTabRows3, tabOpts3);

the border will be 1 and not 2;

for the follow code in addTableDefinition function in gen-object.ts.

// set complete BorderOptions for all sides
				const arrSides = [0, 1, 2, 3]
				arrSides.forEach(idx => {
					newCell.options.border[idx] = {
						type: newCell.options.border[idx].type || DEF_CELL_BORDER.type,
						color: newCell.options.border[idx].color || DEF_CELL_BORDER.color,
						pt: typeof newCell.options.border[idx].pt === 'number' ? newCell.options.border[idx].pt : DEF_CELL_BORDER.pt,
					}
				})

hesi726 avatar May 15 '25 14:05 hesi726

Another strange question,

i remarked the code as follows,

export function genSlides_Table(pptx) {
	pptx.addSection({ title: "Tables" });
	//genSlide01(pptx);
	//genSlide02(pptx);
	//genSlide03(pptx);
	//genSlide04(pptx);
	//genSlide05(pptx);
	//genSlide06(pptx);
	//pptx.addSection({ title: "Tables: Auto-Paging" });
	//genSlide07(pptx);
	//pptx.addSection({ title: "Tables: Auto-Paging Complex" });
	//genSlide08(pptx);
	//pptx.addSection({ title: "Tables: Auto-Paging Calc" });
	//genSlide09(pptx);
	// if (TESTMODE)
	{
		pptx.addSection({ title: "Tables: QA" });
		genSlide10(pptx);
	}
}
···

and run it on node (not in browser)
it tell me :

throw new Error('addTable: Array expected! EX: \'slide.addTable( [rows], {options} );\' (https://gitbrent.github.io/PptxGenJS/docs/api-tables.html)');

in addTableDefinition function 
···js
 if (tableRows === null || tableRows.length === 0 || !Array.isArray(tableRows)) {
     throw new Error('addTable: Array expected! EX: \'slide.addTable( [rows], {options} );\' (https://gitbrent.github.io/PptxGenJS/docs/api-tables.html)');
 }

I cant understand why it can run work in browser and dont work on node.

hesi726 avatar May 15 '25 14:05 hesi726

addChartDefinition function in gen-objects.ts

if (options.dataBorder && (!options.dataBorder.color || typeof options.dataBorder.color !== 'string' || options.dataBorder.color.length !== 6)) { options.dataBorder.color = 'F9F9F9' }

so , if set the color to SchemeColor.text2, it will replaced to 'F9F9F9' ?

hesi726 avatar May 16 '25 15:05 hesi726

Both logged issues are now fixed.

gitbrent avatar Jun 25 '25 22:06 gitbrent