当前位置: 首页>>代码示例>>PHP>>正文


PHP PMA_getColumnAlphaName函数代码示例

本文整理汇总了PHP中PMA_getColumnAlphaName函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getColumnAlphaName函数的具体用法?PHP PMA_getColumnAlphaName怎么用?PHP PMA_getColumnAlphaName使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了PMA_getColumnAlphaName函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: array

                $tempRow[] = $cell;
            }
            $rows[] = $tempRow;
            $tempRow = array();
        }
        if ($_REQUEST['xls_col_names']) {
            $col_names = array_splice($rows, 0, 1);
            $col_names = $col_names[0];
            for ($j = 0; $j < $num_cols; ++$j) {
                if (!strcmp('NULL', $col_names[$j])) {
                    $col_names[$j] = PMA_getColumnAlphaName($j + 1);
                }
            }
        } else {
            for ($n = 0; $n < $num_cols; ++$n) {
                $col_names[] = PMA_getColumnAlphaName($n + 1);
            }
        }
        $tables[] = array($sheet_names[$s], $col_names, $rows);
        $col_names = array();
        $rows = array();
    }
}
unset($objPHPExcel);
unset($objReader);
unset($rows);
unset($tempRow);
unset($col_names);
/* Obtain the best-fit MySQL types for each column */
$analyses = array();
$len = count($tables);
开发者ID:kolbermoorer,项目名称:edugame,代码行数:31,代码来源:xls.php

示例2: doImport


//.........这里部分代码省略.........
                 continue;
             }
             /* Iterate over columns */
             foreach ($row as $cell) {
                 $text = $cell->children('text', true);
                 $cell_attrs = $cell->attributes('office', true);
                 if (count($text) != 0) {
                     $attr = $cell->attributes('table', true);
                     $num_repeat = (int) $attr['number-columns-repeated'];
                     $num_iterations = $num_repeat ? $num_repeat : 1;
                     for ($k = 0; $k < $num_iterations; $k++) {
                         $value = $this->getValue($cell_attrs, $text);
                         if (!$col_names_in_first_row) {
                             $tempRow[] = $value;
                         } else {
                             // MySQL column names can't end with a space
                             // character.
                             $col_names[] = rtrim($value);
                         }
                         ++$col_count;
                     }
                     continue;
                 }
                 $attr = $cell->attributes('table', true);
                 $num_null = (int) $attr['number-columns-repeated'];
                 if ($num_null) {
                     if (!$col_names_in_first_row) {
                         for ($i = 0; $i < $num_null; ++$i) {
                             $tempRow[] = 'NULL';
                             ++$col_count;
                         }
                     } else {
                         for ($i = 0; $i < $num_null; ++$i) {
                             $col_names[] = PMA_getColumnAlphaName($col_count + 1);
                             ++$col_count;
                         }
                     }
                 } else {
                     if (!$col_names_in_first_row) {
                         $tempRow[] = 'NULL';
                     } else {
                         $col_names[] = PMA_getColumnAlphaName($col_count + 1);
                     }
                     ++$col_count;
                 }
             }
             //Endforeach
             /* Find the widest row */
             if ($col_count > $max_cols) {
                 $max_cols = $col_count;
             }
             /* Don't include a row that is full of NULL values */
             if (!$col_names_in_first_row) {
                 if ($_REQUEST['ods_empty_rows']) {
                     foreach ($tempRow as $cell) {
                         if (strcmp('NULL', $cell)) {
                             $tempRows[] = $tempRow;
                             break;
                         }
                     }
                 } else {
                     $tempRows[] = $tempRow;
                 }
             }
             $col_count = 0;
             $col_names_in_first_row = false;
开发者ID:ecssjapan,项目名称:guiding-you-afteropen,代码行数:67,代码来源:ImportOds.class.php

示例3: testGetColumnAlphaName

 /**
  * Test for PMA_getColumnAlphaName
  *
  * @param string $expected Expected result of the function
  * @param int    $num      The column number
  *
  * @return void
  *
  * @dataProvider provGetColumnAlphaName
  */
 function testGetColumnAlphaName($expected, $num)
 {
     $this->assertEquals($expected, PMA_getColumnAlphaName($num));
 }
开发者ID:rclakmal,项目名称:phpmyadmin,代码行数:14,代码来源:PMA_import_test.php

示例4: PMA_getColumnAlphaName

/**
 * Returns the "Excel" column name (i.e. 1 = "A", 26 = "Z", 27 = "AA", etc.)
 *
 * 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 alphabet),
 * 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 added and the complete
 * column name is returned.
 *
 * @param int $num the column number
 *
 * @return string The column's "Excel" name
 * @access  public
 */
function PMA_getColumnAlphaName($num)
{
    $A = 65;
    // ASCII value for capital "A"
    $col_name = "";
    if ($num > 26) {
        $div = (int) ($num / 26);
        $remain = (int) ($num % 26);
        // subtract 1 of divided value in case the modulus is 0,
        // this is necessary because A-Z has no 'zero'
        if ($remain == 0) {
            $div--;
        }
        // recursive function call
        $col_name = PMA_getColumnAlphaName($div);
        // use modulus as new column number
        $num = $remain;
    }
    if ($num == 0) {
        // use 'Z' if column number is 0,
        // this is necessary because A-Z has no 'zero'
        $col_name .= mb_chr($A + 26 - 1);
    } else {
        // convert column number to ASCII character
        $col_name .= mb_chr($A + $num - 1);
    }
    return $col_name;
}
开发者ID:sruthikudaravalli,项目名称:QuickCabs,代码行数:53,代码来源:import.lib.php

示例5: PMA_getColumnAlphaName

/**
 * 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) 
 *
 * @author  Derek Schaefer (derek.schaefer@gmail.com)
 *
 * @access  public
 *
 * @uses    chr()
 * @param   int $num
 * @return  string The column's "Excel" name
 */
function PMA_getColumnAlphaName($num)
{
    /* ASCII value for capital "A" */
    $A = 65;
    $sCol = "";
    $iRemain = 0;
    /* This algorithm only works up to ZZ. it fails on AAA */
    if ($num > 701) {
        return $num;
    } elseif ($num <= 26) {
        if ($num == 0) {
            $sCol = chr($A + 26 - 1);
        } else {
            $sCol = chr($A + $num - 1);
        }
    } else {
        $iRemain = $num / 26 - 1;
        if ($num % 26 == 0) {
            $sCol = PMA_getColumnAlphaName($iRemain) . PMA_getColumnAlphaName($num % 26);
        } else {
            $sCol = chr($A + $iRemain) . PMA_getColumnAlphaName($num % 26);
        }
    }
    return $sCol;
}
开发者ID:kebyn,项目名称:apache_workspace,代码行数:37,代码来源:import.lib.php


注:本文中的PMA_getColumnAlphaName函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。