8

I have a series of divs organized in a neat table format using display: table, table-row and table-cell rules. It looks great, but I've been asked to support users that want to copy the text and paste into excel. In the past, we've had similar reports that are rendered in plain html tables (tr, td etc) and I guess excel knows what to do with that to bring it in appropriately, but for the styled divs they just make one long column (which is not exactly ideal for a useful report).

Is it possible to do this without resorting to an html table?

My question is a simple "Is it possible?". I already have an alternative solution, I just don't want to have to go down that path if there is a better way.

Francisco Garcia
  • 974
  • 1
  • 15
  • 26
  • 2
    I don't think there is really a solution, and if people are copying this into Excel, it suggests to me it is tabular data so a table may be the correct way to display it anyway. – Rhumborl Nov 19 '14 at 14:49
  • this is a perfect answer for me, if you want to actually answer i'll give you the green checkmark. I was looking for some magic trick to get it to work, but i'm old enough to know that magic is usually just hard work in disguise. – Francisco Garcia Nov 19 '14 at 15:40

2 Answers2

6

There is not really a way around this - Excel doesn't take CSS layouts into account so will not interpret it correctly.

Besides, if people are copying this data into Excel, it suggests to me it is actual tabular data so a <table> is probably the correct way to display it anyway - this is why the tag exists and is still valid in HTML5.

Rhumborl
  • 16,349
  • 4
  • 39
  • 45
0

Alternatively you can use a simple CVS download method to export data. Much more simpler and more convenient.

https://stackoverflow.com/a/14966131/2572967

Zortext
  • 566
  • 8
  • 21