Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: cell.style.fill problems #1573

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

fix: cell.style.fill problems #1573

wants to merge 2 commits into from

Conversation

styunan
Copy link

@styunan styunan commented Dec 19, 2020

Summary

After all the borders of (A1: B1) are set, read the excel file, and then change the background color of cell A1. The background color of cell B1 will also change.
create test_a.xlsx

  const wb = new ExcelJS.Workbook();
  const worksheet = wb.addWorksheet('Sheet1');
  const border = {"left":{"style":"thin"},"right":{"style":"thin"},"top":{"style":"thin"},"bottom":{"style":"thin"}};
  worksheet.getCell('A1').style.border = border;
  worksheet.getCell('A1').value = 'A1';
  worksheet.getCell('B1').style.border = border;
  worksheet.getCell('B1').value = 'B1';
  wb.xlsx.writeFile(path.resolve('./spec/unit/doc/test_a.xlsx'));

image
Then read excel

  const wb = new ExcelJS.Workbook();
  const workbook = await wb.xlsx.readFile('./spec/unit/doc/test_a.xlsx');
  workbook.getWorksheet(1).getCell('A1').style.fill = {
    type: 'pattern',
    pattern: 'solid',
    fgColor: { argb: 'FFFF0000' },
    bgColor: { indexed: 64 }
  };
  console.log(workbook.getWorksheet(1).getCell('A1').style.fill === workbook.getWorksheet(1).getCell('B1').style.fill);
  // **true**

  console.log(workbook.getWorksheet(1).getCell('B1').style.fill);
  console.log(workbook.getWorksheet(1).getCell('A1').style.fill);
  workbook.xlsx.writeFile(path.resolve('./spec/unit/doc/test_a0000.xlsx'));

fill A1 with red solid but A2 also red solid
image

Test plan spec\unit\utils

A simple test is included in spec/unit/utils/utils.spec.js

huyunan added 2 commits December 19, 2020 22:16
…hen change the background color of cell A1. The background color of cell B1 will also change.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant