Exporting data from a MySQL database to an Microsoft Excel spreadsheet using PHP

Discussion in 'PHP' started by karl_murphy, Jun 29, 2010.

  1. #1
    Hi,

    I've set up a script to query a database and export the results to a Microsoft Excel spreadsheet. This seems to work fine as the data is exported to the correct cells within the spreadsheet.

    However, one of the fields contains several paragraphs so it is quite large and only a portion of it is exported to the spreadsheet. I've read that Excel only accepts a maxium of 255 characters into each cell. Is there a way around this?

    I'm using PHP scripts to query the database as well as set up the spreadsheet.

    Any help with this would be greatly appreciated.

    Regards,

    Karl
     
    karl_murphy, Jun 29, 2010 IP
  2. Zerix

    Zerix Peon

    Messages:
    18
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #2
    You could split the text up into 255 chunks and then add it into joining cells?

    Have done some reading and apparently all cell content over 255 is truncated. I think there are some work arounds using VB but PHP may not be as capable for it.
     
    Zerix, Jun 29, 2010 IP
  3. mfscripts

    mfscripts Banned

    Messages:
    319
    Likes Received:
    4
    Best Answers:
    8
    Trophy Points:
    90
    Digital Goods:
    3
    #3
    Yeah I dont think you can avoid the 255 limit. Can you export to Excel 2007 as that would permit it? There's a good php class which I've previously used:

    http://phpexcel.codeplex.com/
     
    mfscripts, Jun 29, 2010 IP
  4. karl_murphy

    karl_murphy Member

    Messages:
    82
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    41
    #4
    How exactly would I split the text? Could you give me an example of how I would do this at query level?

    Also, would I just have to manually join the cells once the Excel document is produced?
     
    karl_murphy, Jun 30, 2010 IP