Jump to content

Recommended Posts

I am stuck.  I have to create an .XLS file dynamically with PHP and a datasource.  No problem... except...

 

One of the fields is a long text field with about 3000 characters.  That is well within the cell specs of an XLS file (M$ Excel) but it seems that all the PHP classes I've found, used, or written seem to only allow for 255 characters.  (I can't uses a fake csv/xls files for this particular project)

 

Can anyone share some insight, help, or a link to how to approach this?  I've got about 20 hours on google on this and everyone *SEEMS* to have that limitation in their class. 

 

If I create a "fake" xls with cvs, it does open in excel, and can be "resaved" to proper xls, but I need this to be done by the script (automated).

 

Help!

Link to comment
https://forums.phpfreaks.com/topic/69734-solved-tough-one-xls/
Share on other sites

Sorry about the double post, they don't have a modify button??? I thought the used to...

 

Anyways

 

I forgot to mention that excel 5 has a 255 character limit, but newer excel doesn't.  They way the keep backward compatibility is the convert strings in newer versions to something called a text block (merged cells each with 255 limit?)

 

So, Maybe the answer is not possible in PHP?

 

Just looking for confirmation if so...

 

Thanks...

Link to comment
https://forums.phpfreaks.com/topic/69734-solved-tough-one-xls/#findComment-350391
Share on other sites

for anyone that cares, I got my answer. It this is wrong, someone please correct me. (Actually, I hope I am wrong, as i would LOVE to be able to do this)

 

It seems that you can only put 255 in a cell in excel due to excel 5.0 having that limitation.  M$, to keep backwards compatibility, does some weird cell merge thingy behind the scene giving the impression of a box able to be up to 65k characters.  It is done in excel, not the file as far as i can tell. I don't understand it, neither does anyone else that I can find.

 

There doesn't seem to be a way around this in either php or vb. (at least that I can find) It seems that I can only make it a pseudo excel file (tsv with the xls extension) if I want to include cells greater than 255 characters long.

Link to comment
https://forums.phpfreaks.com/topic/69734-solved-tough-one-xls/#findComment-353454
Share on other sites

I output to a simple tab-delimited text file with .xls extension and can go up to the 65k character limit.

 

I have done that for a long time, but this particular customer spec'd that it be a real xls not tsv/xls. 

 

I just wanted to verify that 255 characters was really the limit for non-tsv format.

 

The one downside to using the TSV format is that text strings (that are numbers i.e. part numbers) loose there leading zero's when you open the spreadsheet.  (they can "turn them on" by changing the field type but only if they know to)

example part number:

0900.120

displays as

900.12

because xls assumes it to be a number.

Can you offer a work around?  It's not a problem if you create a "real" xls files because you can specify the field type.

This particular customer want to use those part numbers AND has a description field greater than 255 characters.

 

Link to comment
https://forums.phpfreaks.com/topic/69734-solved-tough-one-xls/#findComment-353989
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.