Excel - Customise borders
Excel - Customise borders
Kjell
Posts: 3Questions: 0Answers: 0
Hi!
I'm using the excelHtml5 button and tried to style a row.
When using the sample code on https://datatables.net/extensions/buttons/examples/html5/excelBorder.html it works well but it does style every row containing the row number.
For example
$('row c[r*="2"]', sheet).attr('s', '25');
will style every row contaning number 2, e.g. row 2, row 12 and so on.
How can I style only row number 2?
This discussion has been closed.
Replies
If you have a look at the jQuery selector documentation, the
*=
selector is "contains". So you would just usec[r="2"]
to get only row 2.Allan
Yes, that was also my first thought. I did test that plus som other home made variations but I never got it to work.
I get no style at all with
$('row c[r="10"]', sheet).attr('s', '25');
The only time I successfully can style a row is with r*
It styles the row with c[r$="2"] also but cannot get it to work with c[r^="2"] or c[r="2"] (those works with my columns though)
I guess there's something wrong in my scripts and will try with a clean install.
Doh - sorry. I'd forgotten how the
r
attribute works. It contains both the row and column information - e.g.E12
orA1
, etc, which is why the example uses the "contains" selector.Using:
would work. But obviously isn't ideal.
What we really want is a regex selector, but I don't think jQuery provides that option.
I'm not actually sure what the best option for this is. jQuery supports custom selectors - it might be that this would be the best way to go for working with the Open Spreadsheet XML
row c:row(2)
for example.Allan
Thanks for clearing that up for me. I don't have that many columns in this case so selecting A2, B2 C2...would be fine but since you mentioned regex I tried this filter james.padolsey.com/javascript/regex-selector-for-jquery/ and got it to work with
(without knowing what I'm doing)
$('row c:regex(r,^[A-Z]2$)', sheet).attr('s', '25');
Anyway, it does style only the second row now