sorry, wrong version checked in
[phpmyadmin/arisferyanto.git] / libraries / export / htmlexcel.php
blob01ea416eb49ea04d83086be83152e04c0ff471d3
1 <?php
2 /* $Id$ */
3 // vim: expandtab sw=4 ts=4 sts=4:
5 /**
6 * Set of functions used to build CSV dumps of tables
7 */
9 /**
10 * Outputs comment
12 * @param string Text of comment
14 * @return bool Whether it suceeded
16 function PMA_exportComment($text) {
17 return TRUE;
20 /**
21 * Outputs export footer
23 * @return bool Whether it suceeded
25 * @access public
27 function PMA_exportFooter() {
29 </table>
30 </div>
31 </body>
32 </html>
33 <?php
34 return TRUE;
37 /**
38 * Outputs export header
40 * @return bool Whether it suceeded
42 * @access public
44 function PMA_exportHeader() {
45 global $charset, $charset_of_file;
47 <html xmlns:o="urn:schemas-microsoft-com:office:office"
48 xmlns:x="urn:schemas-microsoft-com:office:excel"
49 xmlns="http://www.w3.org/TR/REC-html40">
51 <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
52 <html>
53 <head>
54 <meta http-equiv="Content-type" content="text/html;charset=<?php echo isset($charset_of_file) ? $charset_of_file : $charset; ?>" />
55 <style id="Classeur1_16681_Styles">
56 </style>
58 </head>
59 <body>
61 <div id="Classeur1_16681" align=center x:publishsource="Excel">
63 <table x:str border=0 cellpadding=0 cellspacing=0 width=100% style='border-collapse: collapse'>
64 <?php
66 return TRUE;
69 /**
70 * Outputs database header
72 * @param string Database name
74 * @return bool Whether it suceeded
76 * @access public
78 function PMA_exportDBHeader($db) {
79 return TRUE;
82 /**
83 * Outputs database footer
85 * @param string Database name
87 * @return bool Whether it suceeded
89 * @access public
91 function PMA_exportDBFooter($db) {
92 return TRUE;
95 /**
96 * Outputs create database database
98 * @param string Database name
100 * @return bool Whether it suceeded
102 * @access public
104 function PMA_exportDBCreate($db) {
105 return TRUE;
109 * Outputs the content of a table in CSV format
111 * @param string the database name
112 * @param string the table name
113 * @param string the end of line sequence
114 * @param string the url to go back in case of error
115 * @param string SQL query for obtaining data
117 * @return bool Whether it suceeded
119 * @access public
121 function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
122 global $what;
124 // Gets the data from the database
125 $result = PMA_DBI_query($sql_query, NULL, PMA_DBI_QUERY_UNBUFFERED);
126 $fields_cnt = PMA_DBI_num_fields($result);
128 // If required, get fields name at the first line
129 if (isset($GLOBALS[$what . '_shownames']) && $GLOBALS[$what . '_shownames'] == 'yes') {
130 $schema_insert = '<tr>';
131 for ($i = 0; $i < $fields_cnt; $i++) {
132 $schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
133 } // end for
134 $schema_insert .= '</tr>';
135 if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
136 } // end if
138 // Format the data
139 while ($row = PMA_DBI_fetch_row($result)) {
140 $schema_insert = '<tr>';
141 for ($j = 0; $j < $fields_cnt; $j++) {
142 if (!isset($row[$j]) || is_null($row[$j])) {
143 $value = $GLOBALS[$what . '_replace_null'];
144 } else if ($row[$j] == '0' || $row[$j] != '') {
145 $value = $row[$j];
146 } else {
147 $value = '';
149 $schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
150 } // end for
151 $schema_insert .= '</tr>';
152 if (!PMA_exportOutputHandler($schema_insert)) return FALSE;
153 } // end while
154 PMA_DBI_free_result($result);
156 return TRUE;