Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const targetCell = newSheetInTemplateWorkbook.cell(cell.rowNumber(), cell.columnNumber())
// applying formula if some exists in the cell
if (cell.formula() != null && cell.formula() !== 'SHARED') {
targetCell.formula(cell.formula())
}
// copying number format style to be able to preserve date format or some ther custom format
if (cell.style('numberFormat') != null) {
targetCell.style('numberFormat', cell.style('numberFormat'))
}
const stylesToApply = {}
getXlsxStyleNames().forEach((styleName) => {
if (cell.style(styleName) != null) {
stylesToApply[styleName] = cell.style(styleName)
}
})
if (mergedAddress != null) {
const range = newSheetInTemplateWorkbook.range(mergedAddress).merged(true)
if (Object.keys(stylesToApply).length > 0) {
range.style(stylesToApply)
}
mergedCells[mergedAddress] = true
} else {
if (Object.keys(stylesToApply).length > 0) {
targetCell.style(stylesToApply)