Question posted 2011 · +16 upvotes
I need to export some data from PostgreSQL to Excel (quick customer wish), and the last time Excel had serious problems opening or importing my COPYd csv files (line endings, utf-8 encoding, etc), and it took me an hour at best.
Does someone know a quick, elegant solution that generates a real Excel file? Like a small shell script or the like?
I want this to be done either on my Linux box (Debian 5.0 Lenny) or on Windows (XP or higher).
Accepted answer +14 upvotes
You could install the PostgreSQL ODBC driver on the Windows machine, and then connect Excel to the database like explained in this blog post (except using ODBC rather than OLEDB).
I haven’t tested this. I’m not really sure if this makes it any easier than exporting CSV and fixing it (given what Excel is like).
EDIT (thanks @Tometzky): The best solution is to use the PostgreSQL ODBC driver to connect Microsoft Access to the database and from Access export to Excel.
External references cited (2)
- postgresql.org — PostgreSQL ODBC driver
- blog.mclaughlinsoftware.com — like explained in this blog post
Top excel Q&A (6)
- Shortcut to Apply a Formula to an Entire Column in Excel +335 (2011)
- How should I escape commas and speech marks in CSV files so they work in Excel? +136 (2012)
- Convert xlsx to csv in linux command line +96 (2012)
- How to create a link inside a cell using EPPlus +50 (2011)
- IF statement: how to leave cell blank if condition is false ("" does not work) +44 (2013)
- T-SQL: Export to new Excel file +44 (2012)
excel solutions on this site
.