[export] Native Excel (Spreadsheet_Excel_Writer) improvements
This commit is contained in:
@@ -43,6 +43,8 @@ $HeadURL: https://phpmyadmin.svn.sourceforge.net/svnroot/phpmyadmin/trunk/phpMyA
|
|||||||
+ [querywindow] store sql history in session
|
+ [querywindow] store sql history in session
|
||||||
+ [querywindow] sql history now without db too
|
+ [querywindow] sql history now without db too
|
||||||
+ [querywindow] tweaks in sql history view
|
+ [querywindow] tweaks in sql history view
|
||||||
|
+ [export] Native Excel (Spreadsheet_Excel_Writer) improvements,
|
||||||
|
thanks to Christian Schmidt
|
||||||
|
|
||||||
2.10.1.0 (not released yet)
|
2.10.1.0 (not released yet)
|
||||||
=====================
|
=====================
|
||||||
|
@@ -31,7 +31,7 @@ if ($xls) {
|
|||||||
'force_file' => true,
|
'force_file' => true,
|
||||||
'options' => array(
|
'options' => array(
|
||||||
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
array('type' => 'text', 'name' => 'null', 'text' => 'strReplaceNULLBy'),
|
||||||
array('type' => 'text', 'name' => 'columns', 'text' => 'strPutColNames'),
|
array('type' => 'bool', 'name' => 'columns', 'text' => 'strPutColNames'),
|
||||||
array('type' => 'hidden', 'name' => 'data'),
|
array('type' => 'hidden', 'name' => 'data'),
|
||||||
),
|
),
|
||||||
'options_text' => 'strOptions',
|
'options_text' => 'strOptions',
|
||||||
@@ -160,40 +160,51 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
|
|||||||
global $what;
|
global $what;
|
||||||
global $workbook;
|
global $workbook;
|
||||||
|
|
||||||
$worksheet =& $workbook->addWorksheet($table);
|
|
||||||
$workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
|
$workbook->setTempDir(realpath($GLOBALS['cfg']['TempDir']));
|
||||||
|
|
||||||
// Gets the data from the database
|
// Gets the data from the database
|
||||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||||
$fields_cnt = PMA_DBI_num_fields($result);
|
$fields_cnt = PMA_DBI_num_fields($result);
|
||||||
$col = 0;
|
|
||||||
|
|
||||||
// If required, get fields name at the first line
|
$row = PMA_DBI_fetch_row($result);
|
||||||
if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns'] == 'yes') {
|
for ($sheetIndex = 0; ; $sheetIndex++) {
|
||||||
$schema_insert = '';
|
// Maximum sheet name length is 31 chars - leave 2 for numeric index
|
||||||
for ($i = 0; $i < $fields_cnt; $i++) {
|
$sheetName = substr($table, 0, 29) . ($sheetIndex > 0 ? $sheetIndex : '');
|
||||||
$worksheet->write(0, $i, stripslashes(PMA_DBI_field_name($result, $i)));
|
$worksheet =& $workbook->addWorksheet($sheetName);
|
||||||
} // end for
|
$rowIndex = 0;
|
||||||
$col++;
|
|
||||||
} // end if
|
|
||||||
|
|
||||||
// Format the data
|
// If required, get fields name at the first line
|
||||||
while ($row = PMA_DBI_fetch_row($result)) {
|
if (isset($GLOBALS['xls_columns']) && $GLOBALS['xls_columns']) {
|
||||||
$schema_insert = '';
|
for ($i = 0; $i < $fields_cnt; $i++) {
|
||||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
$worksheet->write(0, $i, stripslashes(PMA_DBI_field_name($result, $i)));
|
||||||
if (!isset($row[$j]) || is_null($row[$j])) {
|
} // end for
|
||||||
$worksheet->write($col, $j, $GLOBALS['xls_null']);
|
$worksheet->repeatRows($rowIndex);
|
||||||
} elseif ($row[$j] == '0' || $row[$j] != '') {
|
$worksheet->freezePanes(array($rowIndex + 1, 0, $rowIndex + 1, 0));
|
||||||
/**
|
$rowIndex++;
|
||||||
* @todo we should somehow handle character set here!
|
} // end if
|
||||||
*/
|
|
||||||
$worksheet->write($col, $j, $row[$j]);
|
// Format the data (max 65536 rows per worksheet)
|
||||||
} else {
|
while ($rowIndex < 65536 && $row) {
|
||||||
$worksheet->write($col, $j, '');
|
set_time_limit(0);
|
||||||
}
|
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||||
} // end for
|
if (!isset($row[$j]) || is_null($row[$j])) {
|
||||||
$col++;
|
$worksheet->write($rowIndex, $j, $GLOBALS['xls_null']);
|
||||||
} // end while
|
} elseif ($row[$j] == '0' || $row[$j] != '') {
|
||||||
|
/**
|
||||||
|
* @todo we should somehow handle character set here!
|
||||||
|
*/
|
||||||
|
$worksheet->write($rowIndex, $j, $row[$j]);
|
||||||
|
} else {
|
||||||
|
$worksheet->write($rowIndex, $j, '');
|
||||||
|
}
|
||||||
|
} // end for
|
||||||
|
$rowIndex++;
|
||||||
|
$row = PMA_DBI_fetch_row($result);
|
||||||
|
} // end while
|
||||||
|
if (!$row) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
} // end for
|
||||||
PMA_DBI_free_result($result);
|
PMA_DBI_free_result($result);
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
Reference in New Issue
Block a user