Home » excel » html – Can I get data in 'display:table'd divs into Excel correctly

html – Can I get data in 'display:table'd divs into Excel correctly

Posted by: admin March 7, 2020 Leave a comment

Questions:

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.

How to&Answers:

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.