tags:

views:

48

answers:

4

Suppose you have a webpage that is displaying data in columns. I'm currently separating them using &nbsp - just to put a nice little white gap in between them. But if you do it this way and paste it into Excel or OOSpreadsheet it will put them all in one column.

Is there a way to format the HTML in such a way that will allow a space to exist in a browser AND can be pasted directly into a spreadsheet?

+1  A: 

Use divs or tables.

Pentium10
Can't entirely agree with the divs. With css positioning the data is often copy/pasted entirely differently then you expected. If have tabular data you want to copy/paste to spreadsheets tables are a perfect solution.
Chris Pebble
+1  A: 

Put a tab break between the columns. The browser will not render whitespace if it's not inside <pre> tags:

Foo&nbsp;\tBar&nbsp;\tEtc

That should make excel behave. Of course, you do not have to write \t, you can just press the TAB key :)

For some reason, I have noticed that even this might not work, but if you paste the data first into Notepad and then into Excel, it will format properly. Beats me.

Tatu Ulmanen
I find it very amusing that Excel can't tell the difference... however going via a Text Editor before the paste into Excel and it working is just ridiculous!
day_trader
+6  A: 

Use tables. And if the URL is not protected, using IE you can export any table to Excel directly.

Teja Kantamneni
A: 

Have you thought about embedding a google or zoho spreadsheet? You can then just download the excel file.

fudgey