1

I'm currently working with the SheetJS library to manipulate an existing Excel sheet, and I need assistance with adding border colors to specific cells. I've already explored the documentation and examples provided by SheetJS, but I couldn't find a solution

Any insights, code snippets, or sample implementations would be greatly appreciated!"

manimk
  • 19
  • 6

2 Answers2

0

Taking a quick look at the sheetjs example demo, you can see that the populated table is a simple HTML table composed of <table/>, <tr/> (rows) and <td/> (cells) among others. See html table documentation.

All you need to do is create a stylesheet (say, my_table.css) and import it in the script that builds thee table (import "./my_table.css") and add a clause for the tr element, as such:

tr {
  border: 1px red;
}

If you're struggling to get the desired result with CSS, I'd recommend reading up more on the css border documentation.

Good luck!

  • I didn't use table, Just read existing excel and get the modified sheet – manimk Dec 26 '22 at 09:09
  • Mate, you need to give me more details. You didn’t even post a snippet or any code examples. I have no idea what you mean by “didn’t use table” and “get the modified sheet”. Without more context the best I can do is guess. – forloopcowboy Dec 27 '22 at 11:07
  • Actually I have excel file having some data, Read that excel file using Sheetjs with reactjs, I read it and i need to add border. How to add styles..? – manimk Dec 27 '22 at 12:05
  • Mate you copy pasted the original question…. – forloopcowboy Dec 28 '22 at 13:22
  • Are you trying to apply the style on what components? What do you mean by “read”? If you have read the data, but not rendered it, what are you trying to style? If you have rendered, which html components did you use, if not table? Do you have links to examples? Code snippets? A repository? Anything? – forloopcowboy Dec 28 '22 at 13:24
  • Dude I read local excel file and modify the data. Here modified row I need to add background color. And finally Export it. Then I open change excel file modified data updated and background color also updated that file – manimk Dec 29 '22 at 07:00
  • You need to re-read what you wrote because it makes no sense. Do you want the style to be applied to the exported file? If so, which format are you using? Or you want to display this table with the desired style using react? It seems this is not a react question. You gotta learn how to ask questions man, good luck with your issue. – forloopcowboy Dec 29 '22 at 09:48
  • Do you want the style to be applied to the exported file? -- YES Thankyou for your concern.. – manimk Dec 29 '22 at 12:16
0

You may exceljs npm

  worksheet.getCell("A1").border = {
       top: { style: 'thin' },
       left: { style: 'thin' },
       bottom: { style: 'thin' },
       right: { style: 'thin' },
  };
manimk
  • 19
  • 6