export the same filtered data with colors
export the same filtered data with colors
In my example. I have some values that are red. I'd like to make them red on the excel export
http://live.datatables.net/fihubuzi/2/edit
As always, thanks for the help
This question has accepted answers - jump to:
This discussion has been closed.
Answers
This thread should help, it's asking the same thing.
Cheers,
Colin
@colin Thanks. Unfortunately, it's not the same. The example is showing logic if the row contains London. I already have the logic done and that's why cells are Red with "<span style="color: red">1234</span>". Would you have an idea to target Span?
Doesn't seem to provide the <span> to filter off of. Only the value
One option is to iterate the rows using
rows().every()
. In the loop check the columns for thespan
color and set the corresponding Excel cell attribute to the format you want using one of the builtin styles. Here is a simple example processing Excel columns B and C:http://live.datatables.net/xehiroqo/1/edit
@colin may have a better suggestion.
Kevin
@kthorngren Thanks! I think that might work. I'll check in the morning to see if @colin has another idea.
I was expecting that span to be in the exported data, so in my link, you could check for that span instead of London. But yep, Kevin's solution is a good one, so go with that
Colin
@colin I was hoping the same thing, but then I looked at the xml. Then it made since why it's not in the xml. Thanks again guys
@colin @kthorngren It appears we have an issue. So Customize goes through each row regardless of selection. I understand that
table.rows({ order: 'applied' }).every(function (rowIdx, tableLoop, rowLoop)
is only what's filtered. This is where it's causing the issue. You have a 1000 rows. You have say 500 filtered. it's going to loop through those 500 filters, 1000 x. On top of that, it doesn't return the correct data in the excel fileI misspoke. table rows are going through each row not Customize
$('row', sheet).each(function (x)
does notOk... Sorry for the confusion (wish I could have deleted the last two lol). I see what's going on. So if I have 1000 row in my table, but filter out 500. I'm marking all the 1000 rows, but not the right row number.
So I'm working on using
table.rows({ order: 'index', search: 'applied' }).each(function (d)
at the moment because it's giving me the rows to look atGood point. You can add the
selector-modifier
of{search: 'applied'}
torows().every()
to handle this. Here is the updated example:http://live.datatables.net/meducaba/1/edit
Resulting in
table.rows({order: 'applied', search: 'applied'}).every( ... )
.Search for
ed
then export.Kevin
@kthorngren Nice. I was going to post
table.rows({ order: 'index', search: 'applied' }).each(function (rowIDs) {
$(rowIDs).each(function (rowID) {