Jump to content

Excel and a cell with a line feed. How to remove it?


mabog

Recommended Posts

Hello.

Trying to get rid a line feed which is coming from a excel cell which has Text and a line feed after that word.

After the excel file has been saved-as tab-delimited, that text transforms to this: "Text"

That line feed is between t and the last double-quote. Hex viewer shows: 22 54 65 78 74 0A 22 so it must be that 0A.

 

I have tried with trim() and with str_replace("\x0A","",$data) but nothing (like \r or \n) works.

 

How do I get rid of that hidden character? Is that \x0A correct?

 

 

Link to comment
Share on other sites

Found the problem.

 

Data (where those 0As are) is a tab-delimited text file created by excel.

That line feed is confusing file handling when trying to get data one row at a time with fgets(). It acts like 0A is a new row..

Tried to add ini_set('auto_detect_line_endings', true); before fopen(), but no change.

 

So those characters would be needed to remove BEFORE the file is opened.

And that, I think, is impossible since files might be quite big.. Going through the file one character at a time for 0A's, is slow...

So it's easier to ask users to remove word warp (that, i belive, is creating 0As) from the excel file before uploading it to my page.

 

No can do.

:shrug:

 

 

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.