Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep color and formatting information in Excel #44

Open
chankeypathak opened this issue Feb 19, 2014 · 19 comments
Open

Keep color and formatting information in Excel #44

chankeypathak opened this issue Feb 19, 2014 · 19 comments

Comments

@chankeypathak
Copy link

If you download the Excel file of table it shows all the content correctly. Kindly add the feature of keeping the formatting and colour information of cells so that the table looks exactly the same as it looks on webpage.

I achieved this without using TableTools here: http://jsfiddle.net/chankeypathak/7cwZ9/1/show/

But I really want to use TableTools. Can you please add this feature? Thanks.

@chankeypathak
Copy link
Author

Sorry, closed by mistake :)

@DataTables
Copy link
Collaborator

The Excel export is really a CSV file. Actually writing an XLSX file, which would be required to keep the formatting, would be a very significant amount of work.

I do hope to do it sometime, but I'm not planning on adding this any time soon, as there are many other features demanding my attention at the moment.

@chankeypathak
Copy link
Author

OK, keep the issue open then.

And thanks for creating DataTables, it's a great tool! :)

@balalinux
Copy link

http://jsfiddle.net/chankeypathak/7cwZ9/1/show/ doesnt seems to work.

TypeError: table is null
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
Could you please fix this ?

Thanks.

@DataTables
Copy link
Collaborator

@balalinux - Your demo doesn't use any code developed by myself. Therefore this is not the appropriate place to ask for help. Either ask on StackOverflow or I'm sure there are plenty of freelancers who would help.

@balalinux
Copy link

@DataTables Sorry Allan. I was referring to @chankeypathak since its his demo. Anyway, I will handle it in private.

Thanks.

@chankeypathak
Copy link
Author

@balalinux : Sorry, refer this link: http://jsfiddle.net/7cwZ9/16/show/

@balalinux
Copy link

Thanks @chankeypathak. I just wanted to see your approach.

@jklaus
Copy link

jklaus commented May 20, 2015

I have actually written a library that implements xlsx.js (for FF & Chrome) and ActiveX (calling Excel.Application, for IE) to support well formatted XLSX export from json. I believe both of these approaches support support cell level styling.. I will actually be digging into that within the next couple days. I was going to make it accessible via an extension/prototype.. but if you want I could add it into the primary table tools.

@p0tvin29
Copy link

p0tvin29 commented Nov 3, 2015

@jklaus are you able to provide your library?

@jklaus
Copy link

jklaus commented Nov 20, 2015

@p0tvin29 yes, take a look at jk

I haven't gotten back around to adding cell level styling though. Given we can probably just drop IE8 (ActiveX) support it should be fairly painless if memory serves. I also have an extension to DataTables that I wrote which provides an "Excel" button to TableTools. It can be overridden to create complex exports or simply implemented and the exporter reflects on the current column options to hook everything up... if you don't get a message back from me in regard to this piece tomorrow feel free to bump this thread.

@jklaus
Copy link

jklaus commented Nov 20, 2015

I went ahead and added a crude version of the file.. see TableTools.Extensions.js

@DataTables
Copy link
Collaborator

I should point out that TableTools has be retired in favour of Buttons. It will export true xlsx files so you might find it easier to add formatting there.

@jklaus
Copy link

jklaus commented Nov 20, 2015

Assuming folks aren't stuck in legacy correct?

@DataTables
Copy link
Collaborator

Yes. I'm no longer actively developing TableTools - but its open source so it can continue if needed!

@jklaus
Copy link

jklaus commented Nov 20, 2015

At the time I was stuck in legacy - had to support IE8, IE11, Chrome, FF, Opera, etc. Now we're finally off IE8.

@xezpeleta
Copy link

I need something similar. I would like to export my table to Excel, keeping the links.

For instance, I have a table with the following column:

<td><a href="about:blank">This is a link</a></td>

When I export my table to Excel, I only can see "This is a link" but it's not linked.

Do you know if is it possible to do that?

Thanks in advance

@BeingWasiZaidi
Copy link

export to xlsx with column background color ?

@Shaheerarain786
Copy link

@BeingWasiZaidi
"buttons": ['pageLength', { extend: 'excel', text: 'Export excel', footer:true, customize: function( xlsx ) { var sheet = xlsx.xl.worksheets['sheet1.xml']; $('row c[r^="G"]', sheet).each( function () { if ( $(this).text()>= 1) { $(this).attr( 's', '56' ); } }); }, exportOptions: { columns: ':visible', } } ],
This is how you can change the background color of your cell while exporting the excel file.
Regards.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

7 participants