n14charlie Posted August 1, 2009 Share Posted August 1, 2009 Hey I'm having problems creating a simple excel file with PHP, I followed this guide: http://www.999tutorials.com/php/create-excel-files-with-php/ But had no luck at creating this simple excel file, I first tried on my web host then on my local host. Here's the code: <?php require_once "excel.php"; $fp = fopen("xlsfile://file.xls", "wb"); if (!is_resource($fp)) { die("Cannot open "); } $data = array( 0 => array( "column1" => "value1", "column2" => "value2", "column3" => "value3", "column4" => "value4", "column5" => "value5", ), 1 => array( "column1" => "value6", "column2" => "value7", "column3" => "value8", "column4" => "value9", "column5" => "value10", ), ); fwrite($fp, $data); fclose($fp); ?> If anyone can point out where I'm wrong or even give me the simplest of examples of how to do it , I'll really appreciate it.. thanks, charlie Link to comment https://forums.phpfreaks.com/topic/168443-create-excel-file-with-php/ Share on other sites More sharing options...
ldougherty Posted August 1, 2009 Share Posted August 1, 2009 So I take it you just copied the script from the URL you posted right, if so what happens when you try and run the script? It should be creating an excel file in your site root. Link to comment https://forums.phpfreaks.com/topic/168443-create-excel-file-with-php/#findComment-888552 Share on other sites More sharing options...
n14charlie Posted August 1, 2009 Author Share Posted August 1, 2009 when I try to run the script it just doesn't echo anything but doesn't do anything either I also tried this example file both on server and my localhost and still nothing : <?php /** * MS-Excel stream handler * Excel export example * @author Ignatius Teo <[email protected]> * @copyright (C)2004 act28.com <http://act28.com> * @date 21 Oct 2004 */ require_once "excel.php"; $export_file = "xlsfile://tmp/example.xls"; $fp = fopen($export_file, "wb"); if (!is_resource($fp)) { die("Cannot open $export_file"); } // typically this will be generated/read from a database table $assoc = array( array("Sales Person" => "Sam Jackson", "Q1" => "$3255", "Q2" => "$3167", "Q3" => 3245, "Q4" => 3943), array("Sales Person" => "Jim Brown", "Q1" => "$2580", "Q2" => "$2677", "Q3" => 3225, "Q4" => 3410), array("Sales Person" => "John Hancock", "Q1" => "$9367", "Q2" => "$9875", "Q3" => 9544, "Q4" => 10255), ); fwrite($fp, serialize($assoc)); fclose($fp); ?> Link to comment https://forums.phpfreaks.com/topic/168443-create-excel-file-with-php/#findComment-888554 Share on other sites More sharing options...
ldougherty Posted August 1, 2009 Share Posted August 1, 2009 Try adding this to the top of the script. ini_set('display_errors', 1); error_reporting(E_ALL); The script not doing anything is likely a PHP error, these lines will display the error if any exists when the script is executed. I assume you've created the excel.php file as well in the same file path right? Link to comment https://forums.phpfreaks.com/topic/168443-create-excel-file-with-php/#findComment-888558 Share on other sites More sharing options...
n14charlie Posted August 1, 2009 Author Share Posted August 1, 2009 It doesn't return any errors, I'm really confused. And ye it uses excel.php I checked it Link to comment https://forums.phpfreaks.com/topic/168443-create-excel-file-with-php/#findComment-888564 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.