cell.fill issue
See original GitHub issuewhen I am using fill style to fill a cell, its also filling other cells. input is,
let xlManipulate = async (email = 'Email ID',filePath) => {
let workbook = new Excel.Workbook();
filePath = path.resolve(__dirname, 'Bulk Download_Upload (1).xlsx');
await workbook.xlsx.readFile(filePath) // reading workbook
let isDirtyFile=0;
let fill = { //cell filling proprerty
type: 'pattern',
pattern: 'darkVertical',
fgColor: { argb: 'FFFFFF00' },
bgColor: { argb: 'FFFFFF0F' }
};
let border = {
diagonal: { up: true, down: true, style: 'thick', color: { argb: 'FFFF0000' } }
};
// let worksheet=workbook.getWorksheet('Consultant Details');
workbook.eachSheet(async (worksheet, sheetId)=> { // reading one sheet at a time
let emailData = new Set();
let lengthOf = 0;
let cellNo = 1;
let rowLength=0;
worksheet.eachRow((row, rowNumber) => { //reading row at a time
//console.log(row.values,rowNumber);
if (rowNumber === 1) { // getting email header index
cellNo = row.values.indexOf(email);
rowLength = row.values.length;
}
//console.log(cellNo);
let cell = row.getCell(cellNo);
emailData.add(cell.value);
if (emailData.size === lengthOf) {
console.log(cell.fill,'++++',cell.value);
cell.fill = fill; //cell filling proprerty
// cell.border=border;
// row.getCell(rowLength).fill=fill;
row.getCell(rowLength).value='duplicate'; // adding comment
//console.log(cell.value);
row.commit();
isDirtyFile=1;
}
else {
console.log(cell.fill,'====',cell.value);
lengthOf = emailData.size;
}
});
});
//Save the workbook
if(isDirtyFile===1)
// await workbook.xlsx.writeFile(filePath);
await workbook.xlsx.writeFile(path.resolve(__dirname, 'Bulk Download_Upload.xlsx'));
return Promise.resolve(isDirtyFile);
}
and the output is,
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Color Fill not working - Microsoft Community Hub
I am trying to do a simple color fill of a cell and it just won't work. What can I do? I have...
Read more >How to Fix When Fill Color Doesn't Display Properly in Excel
First, make sure that the cells you're trying to fill are actually selected. If they're not, the fill color won't show up. Next,...
Read more >Excel drag to “fill” not working – value is copied, formula ignored
You might also run into drag-to-fill issues if you're filtering. Try removing all filters and dragging again.
Read more >Table Cell Shading – White Space – Troubleshooting
When attempting to apply shading to tables, you may meet with the problem that one or more cells are not totally filled with...
Read more >Why Fill Handle Excel not working? | MyExcelOnline
It can even be that you have not selected the entire range that has your sequential values. Just selecting the last cell will...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@ns20011997 it is probably a similar issue like here: https://github.com/exceljs/exceljs/issues/669 (PR: https://github.com/exceljs/exceljs/pull/722)
if I am right, this workaround should works:
Steps :
ws.getCell('B2').font = {...cell.font, color: {argb: 'FF3366FF'}}
Workaround
Idea
May be, create a method
setStyle()
on Cell class.Use example :
become :
Use example :
become :