Outputting Tab Delimited File For Excel

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
justravis
Forum Commoner
Posts: 53
Joined: Mon Dec 16, 2002 3:18 am
Location: San Diego, CA
Contact:

Outputting Tab Delimited File For Excel

Post by justravis »

I have a script outputting a .txt file that seperates fields by \t. When I go to open it in Excel. It says 'SYLK: file format is not valid' The file opend in Notepad, but the words wrap at the wrong places.

Any ideas?

My Excel should open tab delimited text files because it opens 1 I created in Windows Notepad.
User avatar
Weirdan
Moderator
Posts: 5978
Joined: Mon Nov 03, 2003 6:13 pm
Location: Odessa, Ukraine

Post by Weirdan »

try to separate your lines with this sequence "\r\n"
justravis
Forum Commoner
Posts: 53
Joined: Mon Dec 16, 2002 3:18 am
Location: San Diego, CA
Contact:

Post by justravis »

thanx, but it did not make a difference
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: Outputting Tab Delimited File For Excel

Post by TheBentinel.com »

justravis wrote:'SYLK: file format is not valid'
Microsoft had an article about this, does your file by any chance start with "ID"? Meaning, are the first 2 bytes I and D? If so, you'll get this error when you try to open it.

http://support.microsoft.com/default.as ... -US;323626

The workaround is to change the file contents so that isn't the case. Even changing it to "id" instead of "ID" is enough.

Hope it helps!
justravis
Forum Commoner
Posts: 53
Joined: Mon Dec 16, 2002 3:18 am
Location: San Diego, CA
Contact:

WOW!!!!!!!!!!!!!!!!

Post by justravis »

I guess i'm lucky you saw that. It solved THAT problem, which is great. NOBODY seemed to have a solution.

Now I go through the text import wizard. Everything looks great there. When I press Finish, I get the error "File not loaded completely." The workbook shows up, but only the first row is imported.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

Never open stuff in Notepad, I recommend using WordPad instead.

It handles the different line breaks properly, where Notepad only likes "\r\n".
TheBentinel.com
Forum Contributor
Posts: 282
Joined: Wed Mar 10, 2004 1:52 pm
Location: Columbus, Ohio

Re: WOW!!!!!!!!!!!!!!!!

Post by TheBentinel.com »

justravis wrote:only the first row is imported.
Is there anything funky at the end of the row, or the beginning of the next row? something like a binary 0 or something?

If you want to, you can email me the file and I'll see if anything jumps out at me.
Post Reply