Formatting Excel Cell
-
Hello,
Can we format cell with JSreport ?
For example center the cell content and return to the line in the same cell (first name and last name) ?Thanks in advance for your help
-
Hi
change your .xlsx file to .rar file type. Then open it with with winrar. When you open it you will see xl folder. Open that folder. In this folder ther is a file named styles.xml. You can do changes with styles and you can see the changes in jsreport like this
<c r="A{{#adjustRow 1 14}}{{/adjustRow}}" s="20" t="inlineStr"><is><t>{{time}}</t></is></c>
Here s="20" indicates the style number in styles.xml file. This style will be apply to specified cell in column A.
You can observe the styles by opening the sheet1.xml file
-
Thank you, it works !!
But for return to the line have you any idea ?
-
you have row and column (c) in xml file (in worksheets folder. sheet1.xml etc).
if a row added in your template you can change it{{#xlsxReplace "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row[8].c[4]"}} //You must know the row number and column number here.
<c t="n" s="29"><f>AVERAGE(J15:J{{#sum dat.length 14}}{{/sum}})</f></c>
{{/xlsxReplace}}if you dont have added row you can add like that
{{#each dat}}
{{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
<row r="{{#sum 3 15}}{{/sum}}">
<c r="A{{#sum 3 15}}{{/sum}}" s="28" t="inlineStr"><is><t>{{time}}</t></is></c>
..... you can add other rows.
</row>
{{/xlsxAdd}}
{{/each}}You can do any changes by going adress like that "worksheet.sheetData[0].row[8].c[4]". //if row exists.
-
Thank you :)
-
I have a similar problem. I want to style the header column and created a style in the style groups of excel. so the styles.xml under xl directory has a cellstyle.
<cellStyle name="myColHeading" xfId="1"/>
and then I am trying to use that in my template
<c s="myColHeading" t="inlineStr"><is><t>{{this}}</t></is></c>
What am I doing wrong. The style doesn't show?
Thanks,
Rashmi