When you make a Web site, you often experience retrieving lists of data. Typically, users want to download these list data and store them to the client. Of course, when downloading this data, you need a fixed format, so that you can use Excel and other software to read. The simple thing to say is csv/excel data export.
Precautions:
The basic format of the output document is: Column 1, column 2, column 3, ..., column nn
When you format the data, you filter the special characters. For example, "If you do not convert to full angle," can cause confusion in the data format.
Implementation method:
Example: Retrieves a database table, saves the result as a string, formats and filters the special characters, and exports it to the client's CSV file.
ordersearchedit_savecsv.php
? PHP
include ( $_server [ '' Document_root '' ] . " /ftcart/orderinfomanager.class.php " );
include ( $_server [ '' Document_root '' ] . " /ftcart/commonutil.php " );
include ( $_server [ '' Document_root '' ] . " /ftcart/commonconst.php " );
include ( $_server [ '' Document_root '' ] . " /ftcart/commonerrormsg.php " );
include ( $_server [ '' Document_root '' ] . " /webadmin.php " );
$searchcase = New Orderinfomanager ();
$nowTime = microtime_float ();
$searchcase = unserialize ( $_session [ " Order_search_case " ]);
$listcsv = $searchcase -> docsv (); // call Docsv () method
$filename = $nowTime ;
// $filename = Str_replace (":", "", $nowTime);
$filename = Trim ($filename);
echo $filename;
Header ( " content-disposition:attachment; filename=. " . $filename . " . csv " );
Header ( '' Content-type:application/octet-stream '' );
Echo " Annotations No., annotations day, name, residence, branch