2
/* vim: set expandtab sw=4 ts=4 sts=4: */
4
* Set of functions used to build CSV dumps of tables
6
* @package phpMyAdmin-Export-HTMLExcel
7
* @version $Id: htmlexcel.php 11972 2008-11-24 09:14:31Z nijel $
9
if (! defined('PHPMYADMIN')) {
16
if (isset($plugin_list)) {
17
$plugin_list['htmlexcel'] = array(
18
'text' => 'strHTMLExcel',
20
'mime_type' => 'application/vnd.ms-excel',
23
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
24
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
25
array('type' => 'hidden', 'name' => 'data'),
27
'options_text' => 'strOptions',
34
* @param string Text of comment
36
* @return bool Whether it suceeded
38
function PMA_exportComment($text) {
43
* Outputs export footer
45
* @return bool Whether it suceeded
49
function PMA_exportFooter() {
50
if (!PMA_exportOutputHandler('
62
* Outputs export header
64
* @return bool Whether it suceeded
68
function PMA_exportHeader() {
69
global $charset, $charset_of_file;
70
if (!PMA_exportOutputHandler('
71
<html xmlns:o="urn:schemas-microsoft-com:office:office"
72
xmlns:x="urn:schemas-microsoft-com:office:excel"
73
xmlns="http://www.w3.org/TR/REC-html40">
75
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
78
<meta http-equiv="Content-type" content="text/html;charset=' . (isset($charset_of_file) ? $charset_of_file : $charset) .'" />
79
<style id="Classeur1_16681_Styles">
85
<div id="Classeur1_16681" align=center x:publishsource="Excel">
87
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse">
96
* Outputs database header
98
* @param string Database name
100
* @return bool Whether it suceeded
104
function PMA_exportDBHeader($db) {
109
* Outputs database footer
111
* @param string Database name
113
* @return bool Whether it suceeded
117
function PMA_exportDBFooter($db) {
122
* Outputs create database database
124
* @param string Database name
126
* @return bool Whether it suceeded
130
function PMA_exportDBCreate($db) {
135
* Outputs the content of a table in CSV format
137
* @param string the database name
138
* @param string the table name
139
* @param string the end of line sequence
140
* @param string the url to go back in case of error
141
* @param string SQL query for obtaining data
143
* @return bool Whether it suceeded
147
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
150
// Gets the data from the database
151
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
152
$fields_cnt = PMA_DBI_num_fields($result);
154
// If required, get fields name at the first line
155
if (isset($GLOBALS[$what . '_columns'])) {
156
$schema_insert = '<tr>';
157
for ($i = 0; $i < $fields_cnt; $i++) {
158
$schema_insert .= '<td class=xl2216681 nowrap><b>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</b></td>';
160
$schema_insert .= '</tr>';
161
if (!PMA_exportOutputHandler($schema_insert)) {
166
$fields_meta = PMA_DBI_get_fields_meta($result);
169
while ($row = PMA_DBI_fetch_row($result)) {
170
$schema_insert = '<tr>';
171
for ($j = 0; $j < $fields_cnt; $j++) {
172
if (!isset($row[$j]) || is_null($row[$j])) {
173
$value = $GLOBALS[$what . '_null'];
174
} elseif ($row[$j] == '0' || $row[$j] != '') {
179
$schema_insert .= '<td class=xl2216681 nowrap';
180
if ('1' == $fields_meta[$j]->numeric) {
181
$schema_insert .= ' x:num ';
183
$schema_insert .= '>' . htmlspecialchars($value) . '</td>';
185
$schema_insert .= '</tr>';
186
if (!PMA_exportOutputHandler($schema_insert)) {
190
PMA_DBI_free_result($result);