php - export data as excel file -
I can easily export data by simple code, but I have a problem when I export information from J. query to code The data export.php file code is not downloaded as below
& lt; Php include '../../config.php'; Function CleanData (& amp; $ str) {if ($ str == 't') $ str = 'TRUE'; If ($ str == 'f') $ str = 'FALSE'; If preg_match ("/ ^ 0 /", $ str) || Preg_mach ("/ ^ \ +? \ D {8,} $ /", $ str) "); $ out = FOPN ("Php: // output", 'w'); $ flag = wrong; $ result = mysql_query ("select from the staff") or die ('questions fail!'); While (false! == ($ line = Mysql_fetch_assoc ($ results) {if (! $ Flag) {fputcsv ($ out, array_keys ($ line), ',', '' ''); $ flag = true; {$ Row ['photo']! = '') {$ Row ['photo'] = "http: // lo "$ Line [$ line, 'clear data]' 'photo'];} fputcsv ($ out, array_values ($ line), ',', '' ');} Fclose ($ exits) ;;;;;); What is a way to call this file by jquery?
No, you can not do this by javascript using jQuery or any other library, inside the browser calls AJAX JavaScript data in the engine.
But you can use the HTML5 download feature:
& lt; A href = "your_file.xls" download = "YourFile.xls" & gt; Download Excel & lt; / A & gt; and provide the appropriate header in PHP:
header ("content-type: application / vnd.ms-excel; charset = utf-8") ; Header ("content-dispute: attachment; file name = your_file.xls"); Header ("End: 0"); Header ("Cash-Control: Required-Modified, Post Check = 0, Pre-Check = 0"); Header ("Cash-Control: Private", Incorrect); Edit: Although the above will work, I withdraw my words as I got:
Created by, if you need it then ask him for help
Cheers!
Comments
Post a Comment