Tab delimited issue?

Topics: Developer Forum, User Forum
Jun 25, 2009 at 4:57 PM
Edited Jun 25, 2009 at 5:07 PM

I have a file with tabs as the separator. When I try the first simple example at on the file, it saves it fine as an Excel file but the tabs have been changed to a square with a question mark inside of it.

Do I need to do something to handle this case?

I tried \t and \\t with setDelimiter, hasn't helped.

Jun 26, 2009 at 11:29 PM

You mean you tried this?


It should be working. Can you post a full example?

Jun 29, 2009 at 3:24 PM


/** PHPExcel_IOFactory */

include 'PHPExcel/IOFactory.php';


// set headers to redirect output to client browser as a file download

header('Content-Type: application/vnd.openXMLformats-officedocument.spreadsheetml.sheet');

header('Content-Disposition: attachment;filename="myfile.xlsx"');

header('Cache-Control: max-age=0');


//-----Create a reader, set some parameters and read in the file-----

$objReader = PHPExcel_IOFactory::createReader('CSV');





$objPHPExcel = $objReader->load('/home/user/public_html/tab_delimit.txt');


//-----Create a Writer and output the file to the browser-----

$objWriter2007 = PHPExcel_IOFactory::createWriter($objPHPExcel, 'Excel2007');

$objWriter2007->save('php://output');  //push out to the client browser


The tabs end up looking like this (the square chars):

Jun 30, 2009 at 2:18 AM

Ouchh... You will need this:


instead of this:


Jun 30, 2009 at 3:58 PM

Okay, I tried that. Opening the Excel gives me:

Excel cannot open the file 'myfile.xlsx' because the file format or file extension is not valid. Verify that the file has not been corrupted and that the file extension matches the format of the file.

So using single quotes gives me a valid Excel file that can be opened, but has a broken delimiter. Using double quotes won't even let me open the file.

Jun 30, 2009 at 10:15 PM

I'm afraid I would have to see the file because I cannot reconstruct the error. Can you send me a sample CSV file? (erik at phpexcel dot net)