Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to Create excel files in php

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 266
    Comment on it

    Applications that are written in php most of the times need to export data for some purposes. In this tutorial, we will learn "How to export that data in Excel CSV fomat?" CSV is known as the EXCEL spreadsheet that have the data in a grid format.

     

    There are many libraries available for php like Spreadsheet_Excel_Writer that can help to save the data in different format. Sometimes these libraries difficult to install. In this we can learn to get the csv format by using a simple few lines code.It will export the simple grid format.

     

    simple format is csv : comma separated values format which can be opened in applications like ms-excel . It can be written as :

    $data = '"Name","City","Country"' . "n";
    $data .= '"abc","Dehradun","India"' . "n";
    $data .= '"abcde","Dehradun","India"' . "n";
     
    $f = fopen('data.csv' , 'wb');
    fwrite($f , $data );
    fclose($f);

    The above code is the powerful ways of representing tabular data from a database.

    If you want some complex tabular form then you can use the library phpexcel from codeplex.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: