Excel export delimited text macro

I often need to save text from Excel to use with PHP, but I find Excel's "Save As" functionality less that useful, as it converts your open worksheet to a text, which is a real pain.

This macro exports the current worksheet as a tab-delimited or comma-delimited text file, with the following features:

  • optionally exports the current selection
  • outputs values as text
  • strips leading and trailing whitespace
  • quotes any cells with spaces (TSV only)
  • warns if the file is locked

Here's an example of the two file outputs:

Tab-separated values

id	word	words
1	hello	"hello there"
2	goodbye	"goodbye then"
3	a	"a, b, c"

Comma-separated values

id,word,words
1,hello,hello there
2,goodbye,goodby then
3,a,a, b, c

Download ExportDelimitedText

2 Comments

  1. alle

    I recently found this, I don't know if it could be helpful to you: http://code.google.com/p/php-excel-reader/