How to make text crossed out in a cell. Xlsx Recipe
-
How to make text crossed out in a cell ? I use xlsx recipe, thank you in advance.
-
There are several possible ways.
Probably the easiest is to style one cell using office application to the desired needs.
Remove the styled cell using the$xlsxRemove
helper and use the same style for the new rows which you want to have crossed.
See the demo here https://playground.jsreport.net/w/jan_blaha/kX_zXooeThe main idea is in this code
{{!-- remove the first row, that includes styled cell with text cross --}} {{xlsxRemove "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row" 0}} {{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}} <row> {{!-- use the same style that was prepared in the office app --}} <c t="inlineStr" s="{{$removedItem.c.[0].$.s}}"><is><t>I want to be crossed</t></is></c> </row> {{/xlsxAdd}} {{{xlsxPrint}}}
-
Thank you very much for your reply, but if i use this s="{{$removedItem.c.[0].$.s}}" in {{#each}} , excel file become damaged, its possible to use s="{{$removedItem.c.[0].$.s}}" in {{#each}}
{{xlsxRemove "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row" 0}}
{{#xlsxAdd "xl/worksheets/sheet1.xml" "worksheet.sheetData[0].row"}}
<row>
{{#each columns}}
<c t="inlineStr" s="{{$removedItem.c.[0].$.s}}"><is><t>Crossed Text</t></is></c>
{{/each}}
</row>
{{/xlsxAdd}}{{{xlsxPrint}}}
-
The
$removedItem
is a property on the root context.
When you are insideeach
the context is changed to the current item.
This means you need to use the expression to get the$removedItem
from the root context.
In handlebars this can be done using{{@root.$removedItem}}
https://handlebarsjs.com/api-reference/data-variables.html#root