Closed th3ygen closed 4 years ago
Hello, I tried to align a merged cells value both vertically and horizontally. The value inside the cells did aligned but only horizontal.
Here's my code
const totalIndex = 3; for (let x = 0; x < totalIndex; x++) { wb.Sheets.Data[`A${(x * 4) + 5}`] = { t: 's', v: `${x + 1}`, s: { fill: { style: 'solid', fgColor: { rgb: 'baff4c' } }, border: { top: { style: 'thin', color: { rgb: '000' } }, right: { style: 'thin', color: { rgb: '000' } }, left: { style: 'thin', color: { rgb: '000' } }, }, alignment: { vertical: 'center', horizontal: 'center' } } }; wb.Sheets.Data['!merges'].push({ s: { r: (x * 4) + 4, c: 0 }, e: { r: (x * 4) + 7, c: 0 }}); wb.Sheets.Data[`A${(x * 4) + 6}`] = { s: { border: { left: { style: 'thin', color: { rgb: '000' } }, right: { style: 'thin', color: { rgb: '000' } }, } } }; wb.Sheets.Data[`A${(x * 4) + 7}`] = { s: { border: { left: { style: 'thin', color: { rgb: '000' } }, right: { style: 'thin', color: { rgb: '000' } }, } } }; wb.Sheets.Data[`A${(x * 4) + 8}`] = { s: { border: { left: { style: 'thin', color: { rgb: '000' } }, right: { style: 'thin', color: { rgb: '000' } }, bottom: { style: 'medium', color: { rgb: '000' } }, } } }; }
Result
Hello, I tried to align a merged cells value both vertically and horizontally. The value inside the cells did aligned but only horizontal.
Here's my code
Result