Merge branch 'QA_3_3'
Conflicts: ChangeLog libraries/import.lib.php
This commit is contained in:
@@ -101,6 +101,7 @@ master, todo: update PHP excel?)
|
|||||||
- 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
|
||||||
|
|
||||||
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
|
||||||
|
@@ -343,27 +343,42 @@ function PMA_getColumnAlphaName($num)
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the column number based on the Excel name.
|
* Returns the column number based on the Excel name.
|
||||||
* So "A" = 1, "AZ" = 27, etc.
|
* So "A" = 1, "Z" = 26, "AA" = 27, etc.
|
||||||
*
|
*
|
||||||
|
* Basicly this is a base26 (A-Z) to base10 (0-9) conversion.
|
||||||
|
* It iterates through all characters in the column name and
|
||||||
|
* calculates the corresponding value, based on character value
|
||||||
|
* (A = 1, ..., Z = 26) and position in the string.
|
||||||
*
|
*
|
||||||
* @access public
|
* @access public
|
||||||
*
|
*
|
||||||
* @uses strtoupper()
|
* @uses strtoupper()
|
||||||
* @uses strlen()
|
* @uses strlen()
|
||||||
* @uses count()
|
|
||||||
* @uses ord()
|
* @uses ord()
|
||||||
* @param string $name (i.e. "A", or "BC", etc.)
|
* @param string $name (i.e. "A", or "BC", etc.)
|
||||||
* @return int The column number
|
* @return int The column number
|
||||||
*/
|
*/
|
||||||
function PMA_getColumnNumberFromName($name) {
|
function PMA_getColumnNumberFromName($name) {
|
||||||
if (strlen($name) != 0) {
|
if (!empty($name)) {
|
||||||
$name = strtoupper($name);
|
$name = strtoupper($name);
|
||||||
$num_chars = count($name);
|
$num_chars = strlen($name);
|
||||||
$number = 0;
|
$column_number = 0;
|
||||||
for ($i = 0; $i < $num_chars; ++$i) {
|
for ($i = 0; $i < $num_chars; ++$i) {
|
||||||
$number += (ord($name[$i]) - 64);
|
// read string from back to front
|
||||||
|
$char_pos = ($num_chars - 1) - $i;
|
||||||
|
|
||||||
|
// convert capital character to ASCII value
|
||||||
|
// and subtract 64 to get corresponding decimal value
|
||||||
|
// ASCII value of "A" is 65, "B" is 66, etc.
|
||||||
|
// Decimal equivalent of "A" is 1, "B" is 2, etc.
|
||||||
|
$number = (ord($name[$char_pos]) - 64);
|
||||||
|
|
||||||
|
// base26 to base10 conversion : multiply each number
|
||||||
|
// with corresponding value of the position, in this case
|
||||||
|
// $i=0 : 1; $i=1 : 26; $i=2 : 676; ...
|
||||||
|
$column_number += $number * pow(26,$i);
|
||||||
}
|
}
|
||||||
return $number;
|
return $column_number;
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user