2
/* $Id: htmlexcel.php 9315 2006-08-16 09:10:23Z nijel $ */
3
// vim: expandtab sw=4 ts=4 sts=4:
6
* Set of functions used to build CSV dumps of tables
9
if (isset($plugin_list)) {
10
$plugin_list['htmlexcel'] = array(
11
'text' => 'strHTMLExcel',
13
'mime_type' => 'application/vnd.ms-excel',
16
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
17
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
18
array('type' => 'hidden', 'name' => 'data'),
20
'options_text' => 'strHTMLExcelOptions',
27
* @param string Text of comment
29
* @return bool Whether it suceeded
31
function PMA_exportComment($text) {
36
* Outputs export footer
38
* @return bool Whether it suceeded
42
function PMA_exportFooter() {
43
if (!PMA_exportOutputHandler('
55
* Outputs export header
57
* @return bool Whether it suceeded
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">
68
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
71
<meta http-equiv="Content-type" content="text/html;charset=' . ( isset($charset_of_file) ? $charset_of_file : $charset ) .'" />
72
<style id="Classeur1_16681_Styles">
78
<div id="Classeur1_16681" align=center x:publishsource="Excel">
80
<table x:str border=0 cellpadding=0 cellspacing=0 width=100% style="border-collapse: collapse">
89
* Outputs database header
91
* @param string Database name
93
* @return bool Whether it suceeded
97
function PMA_exportDBHeader($db) {
102
* Outputs database footer
104
* @param string Database name
106
* @return bool Whether it suceeded
110
function PMA_exportDBFooter($db) {
115
* Outputs create database database
117
* @param string Database name
119
* @return bool Whether it suceeded
123
function PMA_exportDBCreate($db) {
128
* Outputs the content of a table in CSV format
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
136
* @return bool Whether it suceeded
140
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
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);
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>';
153
$schema_insert .= '</tr>';
154
if (!PMA_exportOutputHandler($schema_insert)) {
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] != '') {
170
$schema_insert .= '<td class=xl2216681 nowrap>' . htmlspecialchars($value) . '</td>';
172
$schema_insert .= '</tr>';
173
if (!PMA_exportOutputHandler($schema_insert)) {
177
PMA_DBI_free_result($result);