Open kimberlydb opened 8 years ago
I've never try this, but the documentation show the cell.h attribute for "rich text" via html.
You could try with something like this :
var my_bold_cell = {
v: "this is my BOLD text",
h: "this is my <b>BOLD</b> text"
}
@kimberlydb did you get this to work?
I did not. I ended up splitting them into different cells and styling them separately.
@kimberlydb thanks for getting back with me. Looks like the only option for now.
Hi @kimberlydb, Can you please share your code on how to add style to cells? I am unable to do the same. Here is my code below,
import * as XLSX from 'xlsx';
const worksheet: XLSX.WorkSheet = XLSX.utils.json_to_sheet(jsonData); const workbook: XLSX.WorkBook = { Sheets: { 'attributes list': worksheet }, SheetNames: ['attributes list'], }; worksheet.A1.v = "Attribute Name"; worksheet.A1.s = { font: { bold: true } }; XLSX.writeFile(workbook, "attributeList" + ".xlsx");
The exported file do not show cell A1 as bold. I tried using XLSX.writeFile(workbook, "attributeList" + ".xlsx", { cellStyles: true }); but did not work.
I am stuck on this long time. Will appreciate your help.
Thanks.
@nikhil18sharma eg.
var headerText = {
font: {
color: {rgb: "FF4F81BD"},
name: "Franklin Gothic Medium", sz: 16
},
border: {
left: {
color: {auto: 1}
},
top: {
color: {auto: 1}
},
right: {
color: {auto: 1}
}
},
fill: {
fgColor: { rgb: "FFFFFFFF"}
}
};
workbook.setCell(fwSheets.intro, 0, 2, {v: "INTRO TEXT", s: headerText });
Wondering how I could have a cell where only part of the cell is styled. eg:
{ v: "this is my BOLD text" s: { font: { bold: true } } }