MS SQL to .xls

  • Hi, I have a problem, how to export one of my tables into a microsoft excel worksheet? I want to do it from a php script. Regards.....<>

  • This was removed by the editor as SPAM

  • It depends on what users want to do with the excel sheet.

    If they just want to see the data in excel sheet, you can see alternatives I or II

    otherwise see alternatives III and IV.

    Alternative 1:

     If you create a text file in csv format, the excel can directly read it.

    Alternative II:

     Microsoft Excel respects the HTML Table tags and opens data directly.

     Hence you can export the data to a text file together with html tags and name the

            file as .xls and provide the download link.

     

     i.e.,with in php script, open the data record set and append html tags and write it to a text file

      <TABLE>

      <TH><TD>COl1 Hdr</TD> ....</TH>

      <TR><TD>COL1</TD>...</TR>

      ...

      <TABLE>

     If you write to text file in this format, excel will directly read it.

    Alternative III:

     You can create excel documents on server using excel automation activex object.

     <?php

     // create an object instance

     $excel = new COM("Excel.Application") or die("Excel could not be

     started");

     ?>

     

     However note that this requires MS office to be installed on web server and

     there may be memory issues with this approach.

     You can also use Office Web Componets for this approach

    Alternative IV:

     There are third party tools available to create excel document without using office.

     check this site http://officewriter.softartisans.com/officewriter-37.aspx

    Hope this helps.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply