The branch, master has been updated via 17fc1370f31ee8be51d5796e3e72252e96e4590e (commit) via 6648c620d917300bfddf6d90555976589844ec19 (commit) via 8b8562b435c81d72c02e38e1135d5fe0fa48d711 (commit) via 64a2832ac89bcb29f5e7e894cabc21d7a50870b0 (commit) via ee0b2895ce966f62e26185ee92a8bf6e41f4fd41 (commit) via b90a1b496b96d1058e152cb7d33bb13ee39ba66f (commit) via 798def6e4505ae239c4bd8c4a2754da534bc736e (commit) from d7b824899783282fe59b7c541d3d88fb5e051738 (commit)
- Log ----------------------------------------------------------------- commit 17fc1370f31ee8be51d5796e3e72252e96e4590e Merge: d7b824899783282fe59b7c541d3d88fb5e051738 6648c620d917300bfddf6d90555976589844ec19 Author: Dieter Adriaenssens ruleant@users.sourceforge.net Date: Tue Jul 13 23:27:15 2010 +0200
Merge branch 'QA_3_3'
Conflicts:
ChangeLog libraries/import.lib.php
-----------------------------------------------------------------------
Summary of changes: ChangeLog | 1 + libraries/import.lib.php | 29 ++++++++++++++++++++++------- 2 files changed, 23 insertions(+), 7 deletions(-)
diff --git a/ChangeLog b/ChangeLog index 8a25731..07c9a76 100644 --- a/ChangeLog +++ b/ChangeLog @@ -101,6 +101,7 @@ master, todo: update PHP excel?) - bug #3023507 [core] No result set display from stored procedure SELECT - bug [export] CSV for MS Excel (Windows) should have semi-colon as separator - [core] Update library PHPExcel to version 1.7.3c +- bug #2994885 [import] Convert Excel column name correctly
3.3.4.0 (2010-06-28) - bug #2996161 [import] properly escape import value diff --git a/libraries/import.lib.php b/libraries/import.lib.php index e012287..cd8741c 100644 --- a/libraries/import.lib.php +++ b/libraries/import.lib.php @@ -343,27 +343,42 @@ function PMA_getColumnAlphaName($num)
/** * 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 * * @uses strtoupper() * @uses strlen() - * @uses count() * @uses ord() * @param string $name (i.e. "A", or "BC", etc.) * @return int The column number */ function PMA_getColumnNumberFromName($name) { - if (strlen($name) != 0) { + if (!empty($name)) { $name = strtoupper($name); - $num_chars = count($name); - $number = 0; + $num_chars = strlen($name); + $column_number = 0; 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 { return 0; }
hooks/post-receive