Merge branch 'QA_3_3'

Conflicts:

	libraries/import.lib.php
This commit is contained in:
Dieter Adriaenssens
2010-07-14 22:32:10 +02:00
2 changed files with 43 additions and 27 deletions

View File

@@ -100,7 +100,7 @@ $Id$
- bug #3023507 [core] No result set display from stored procedure SELECT - bug #3023507 [core] No result set display from stored procedure SELECT
- bug [export] CSV for MS Excel (Windows) should have semi-colon as separator - bug [export] CSV for MS Excel (Windows) should have semi-colon as separator
- [core] Update library PHPExcel to version 1.7.3c - [core] Update library PHPExcel to version 1.7.3c
- bug #2994885 [import] Convert Excel column name correctly - bug #2994885, bug #3029168 [import] Convert Excel column name correctly
3.3.4.0 (2010-06-28) 3.3.4.0 (2010-06-28)
- bug #2996161 [import] properly escape import value - bug #2996161 [import] properly escape import value

View File

@@ -304,7 +304,19 @@ function PMA_importGetNextChunk($size = 32768)
/** /**
* Returns the "Excel" column name (i.e. 1 = "A", 26 = "Z", 27 = "AA", etc.) * Returns the "Excel" column name (i.e. 1 = "A", 26 = "Z", 27 = "AA", etc.)
* This algorithm only works up to ZZ. it fails on AAA (up to 701 columns) *
* This functions uses recursion to build the Excel column name.
*
* The column number (1-26) is converted to the responding ASCII character (A-Z) and returned.
*
* If the column number is bigger than 26 (= num of letters in alfabet),
* an extra character needs to be added. To find this extra character, the number is divided by 26
* and this value is passed to another instance of the same function (hence recursion).
* In that new instance the number is evaluated again, and if it is still bigger than 26, it is divided again
* and passed to another instance of the same function. This continues until the number is smaller than 26.
* Then the last called function returns the corresponding ASCII character to the function that called it.
* Each time a called function ends an extra character is added to the column name.
* When the first function is reached, the last character is addded and the complete column name is returned.
* *
* @access public * @access public
* *
@@ -314,31 +326,35 @@ function PMA_importGetNextChunk($size = 32768)
*/ */
function PMA_getColumnAlphaName($num) function PMA_getColumnAlphaName($num)
{ {
/* ASCII value for capital "A" */ $A = 65; // ASCII value for capital "A"
$A = 65; $col_name = "";
$sCol = "";
$iRemain = 0; if ($num > 26) {
$div = (int)($num / 26);
/* This algorithm only works up to ZZ. it fails on AAA */ $remain = (int)($num % 26);
if ($num > 701) { // subtract 1 of divided value in case the modulus is 0,
return $num; // this is necessary because A-Z has no 'zero'
} elseif ($num <= 26) { if ($remain == 0) {
if ($num == 0) { $div--;
$sCol = chr(($A + 26) - 1); }
} else {
$sCol = chr(($A + $num) - 1); // recursive function call
} $col_name = PMA_getColumnAlphaName($div);
} else { // use modulus as new column number
$iRemain = (($num / 26)) - 1; $num = $remain;
if (($num % 26) == 0) { }
$sCol = PMA_getColumnAlphaName($iRemain) . PMA_getColumnAlphaName($num % 26);
} else { if ($num == 0) {
$sCol = chr($A + $iRemain) . PMA_getColumnAlphaName($num % 26); // use 'Z' if column number is 0,
} // this is necessary because A-Z has no 'zero'
} $col_name .= chr(($A + 26) - 1);
} else {
return $sCol; // convert column number to ASCII character
$col_name .= chr(($A + $num) - 1);
}
return $col_name;
} }
/** /**