[ Index ] |
|
Code source de phpMyAdmin 2.10.3 |
1 <?php 2 /* $Id: htmlexcel.php 9315 2006-08-16 09:10:23Z nijel $ */ 3 // vim: expandtab sw=4 ts=4 sts=4: 4 5 /** 6 * Set of functions used to build CSV dumps of tables 7 */ 8 9 if (isset($plugin_list)) { 10 $plugin_list['htmlexcel'] = array( 11 'text' => 'strHTMLExcel', 12 'extension' => 'xls', 13 'mime_type' => 'application/vnd.ms-excel', 14 'force_file' => true, 15 'options' => array( 16 array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'), 17 array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'), 18 array('type' => 'hidden', 'name' => 'data'), 19 ), 20 'options_text' => 'strHTMLExcelOptions', 21 ); 22 } else { 23 24 /** 25 * Outputs comment 26 * 27 * @param string Text of comment 28 * 29 * @return bool Whether it suceeded 30 */ 31 function PMA_exportComment($text) { 32 return TRUE; 33 } 34 35 /** 36 * Outputs export footer 37 * 38 * @return bool Whether it suceeded 39 * 40 * @access public 41 */ 42 function PMA_exportFooter() { 43 if (!PMA_exportOutputHandler(' 44 </table> 45 </div> 46 </body> 47 </html> 48 ')) { 49 return FALSE; 50 } 51 return TRUE; 52 } 53 54 /** 55 * Outputs export header 56 * 57 * @return bool Whether it suceeded 58 * 59 * @access public 60 */ 61 function PMA_exportHeader() { 62 global $charset, $charset_of_file; 63 if (!PMA_exportOutputHandler(' 64 <html xmlns:o="urn:schemas-microsoft-com:office:office" 65 xmlns:x="urn:schemas-microsoft-com:office:excel" 66 xmlns="http://www.w3.org/TR/REC-html40"> 67 68 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 69 <html> 70 <head> 71 <meta http-equiv="Content-type" content="text/html;charset=' . ( isset($charset_of_file) ? $charset_of_file : $charset ) .'" /> 72 <style id="Classeur1_16681_Styles"> 73 </style> 74 75 </head> 76 <body> 77 78 <div id="Classeur1_16681" align=center x:publishsource="Excel"> 79 80 <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse"> 81 ')) { 82 return FALSE; 83 } 84 85 return TRUE; 86 } 87 88 /** 89 * Outputs database header 90 * 91 * @param string Database name 92 * 93 * @return bool Whether it suceeded 94 * 95 * @access public 96 */ 97 function PMA_exportDBHeader($db) { 98 return TRUE; 99 } 100 101 /** 102 * Outputs database footer 103 * 104 * @param string Database name 105 * 106 * @return bool Whether it suceeded 107 * 108 * @access public 109 */ 110 function PMA_exportDBFooter($db) { 111 return TRUE; 112 } 113 114 /** 115 * Outputs create database database 116 * 117 * @param string Database name 118 * 119 * @return bool Whether it suceeded 120 * 121 * @access public 122 */ 123 function PMA_exportDBCreate($db) { 124 return TRUE; 125 } 126 127 /** 128 * Outputs the content of a table in CSV format 129 * 130 * @param string the database name 131 * @param string the table name 132 * @param string the end of line sequence 133 * @param string the url to go back in case of error 134 * @param string SQL query for obtaining data 135 * 136 * @return bool Whether it suceeded 137 * 138 * @access public 139 */ 140 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) { 141 global $what; 142 143 // Gets the data from the database 144 $result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED); 145 $fields_cnt = PMA_DBI_num_fields($result); 146 147 // If required, get fields name at the first line 148 if (isset($GLOBALS[$what . '_columns'])) { 149 $schema_insert = '<tr>'; 150 for ($i = 0; $i < $fields_cnt; $i++) { 151 $schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>'; 152 } // end for 153 $schema_insert .= '</tr>'; 154 if (!PMA_exportOutputHandler($schema_insert)) { 155 return FALSE; 156 } 157 } // end if 158 159 // Format the data 160 while ($row = PMA_DBI_fetch_row($result)) { 161 $schema_insert = '<tr>'; 162 for ($j = 0; $j < $fields_cnt; $j++) { 163 if (!isset($row[$j]) || is_null($row[$j])) { 164 $value = $GLOBALS[$what . '_null']; 165 } elseif ($row[$j] == '0' || $row[$j] != '') { 166 $value = $row[$j]; 167 } else { 168 $value = ''; 169 } 170 $schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>'; 171 } // end for 172 $schema_insert .= '</tr>'; 173 if (!PMA_exportOutputHandler($schema_insert)) { 174 return FALSE; 175 } 176 } // end while 177 PMA_DBI_free_result($result); 178 179 return TRUE; 180 } 181 182 } 183 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Mon Nov 26 15:18:20 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |