当前路径:Classes/PHPExcel/Calculation/LookupRef.php <?php /** PHPExcel root directory */ if (!defined('PHPEXCEL_ROOT')) { /** * @ignore */ define('PHPEXCEL_ROOT', dirname(__FILE__) . '/../../'); require(PHPEXCEL_ROOT . 'PHPExcel/Autoloader.php'); } /** * PHPExcel_Calculation_LookupRef * * Copyright (c) 2006 - 2015 PHPExcel * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public * License as published by the Free Software Foundation; either * version 2.1 of the License, or (at your option) any later version. * * This library is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public * License along with this library; if not, write to the Free Software * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * * @category PHPExcel * @package PHPExcel_Calculation * @copyright Copyright (c) 2006 - 2015 PHPExcel (http://www.codeplex.com/PHPExcel) * @license http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt LGPL * @version ##VERSION##, ##DATE## */ class PHPExcel_Calculation_LookupRef { /** * CELL_ADDRESS * * Creates a cell address as text, given specified row and column numbers. * * Excel Function: * =ADDRESS(row, column, [relativity], [referenceStyle], [sheetText]) * * @param row Row number to use in the cell reference * @param column Column number to use in the cell reference * @param relativity Flag indicating the type of reference to return * 1 or omitted Absolute * 2 Absolute row; relative column * 3 Relative row; absolute column * 4 Relative * @param referenceStyle A logical value that specifies the A1 or R1C1 reference style. * TRUE or omitted CELL_ADDRESS returns an A1-style reference * FALSE CELL_ADDRESS returns an R1C1-style reference * @param sheetText Optional Name of worksheet to use * @return string */ public static function CELL_ADDRESS($row, $column, $relativity = 1, $referenceStyle = true, $sheetText = '') { $row = PHPExcel_Calculation_Functions::flattenSingleValue($row); $column = PHPExcel_Calculation_Functions::flattenSingleValue($column); $relativity = PHPExcel_Calculation_Functions::flattenSingleValue($relativity); $sheetText = PHPExcel_Calculation_Functions::flattenSingleValue($sheetText); if (($row < 1) || ($column < 1)) { return PHPExcel_Calculation_Functions::VALUE(); } if ($sheetText > '') { if (strpos($sheetText, ' ') !== false) { $sheetText = "'".$sheetText."'"; } $sheetText .='!'; } if ((!is_bool($referenceStyle)) || $referenceStyle) { $rowRelative = $columnRelative = '$'; $column = PHPExcel_Cell::stringFromColumnIndex($column-1); if (($relativity == 2) || ($relativity == 4)) { $columnRelative = ''; } if (($relativity == 3) || ($relativity == 4)) { $rowRelative = ''; } return $sheetText.$columnRelative.$column.$rowRelative.$row; } else { if (($relativity == 2) || ($relativity == 4)) { $column = '['.$column.']'; } if (($relativity == 3) || ($relativity == 4)) { $row = '['.$row.']'; } return $sheetText.'R'.$row.'C'.$column; } } /** * COLUMN * * Returns the column number of the given cell reference * If the cell reference is a range of cells, COLUMN returns the column numbers of each column in the reference as a horizontal array. * If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the * reference of the cell in which the COLUMN function appears; otherwise this function returns 0. * * Excel Function: * =COLUMN([cellAddress]) * * @param cellAddress A reference to a range of cells for which you want the column numbers * @return integer or array of integer */ public static function COLUMN($cellAddress = null) { if (is_null($cellAddress) || trim($cellAddress) === '') { return 0; } if (is_array($cellAddress)) { foreach ($cellAddress as $columnKey => $value) { $columnKey = preg_replace('/[^a-z]/i', '', $columnKey); return (integer) PHPExcel_Cell::columnIndexFromString($columnKey); } } else { if (strpos($cellAddress, '!') !== false) { list($sheet, $cellAddress) = explode('!', $cellAddress); } if (strpos($cellAddress, ':') !== false) { list($startAddress, $endAddress) = explode(':', $cellAddress); $startAddress = preg_replace('/[^a-z]/i', '', $startAddress); $endAddress = preg_replace('/[^a-z]/i', '', $endAddress); $returnValue = array(); do { $returnValue[] = (integer) PHPExcel_Cell::columnIndexFromString($startAddress); } while ($startAddress++ != $endAddress); return $returnValue; } else { $cellAddress = preg_replace('/[^a-z]/i', '', $cellAddress); return (integer) PHPExcel_Cell::columnIndexFromString($cellAddress); } } } /** * COLUMNS * * Returns the number of columns in an array or reference. * * Excel Function: * =COLUMNS(cellAddress) * * @param cellAddress An array or array formula, or a reference to a range of cells for which you want the number of columns * @return integer The number of columns in cellAddress */ public static function COLUMNS($cellAddress = null) { if (is_null($cellAddress) || $cellAddress === '') { return 1; } elseif (!is_array($cellAddress)) { return PHPExcel_Calculation_Functions::VALUE(); } reset($cellAddress); $isMatrix = (is_numeric(key($cellAddress))); list($columns, $rows) = PHPExcel_Calculation::_getMatrixDimensions($cellAddress); if ($isMatrix) { return $rows; } else { return $columns; } } /** * ROW * * Returns the row number of the given cell reference * If the cell reference is a range of cells, ROW returns the row numbers of each row in the reference as a vertical array. * If cell reference is omitted, and the function is being called through the calculation engine, then it is assumed to be the * ref...
完整源码文件,请先购买后再查看
相关源码
- JAVA+SPRINGBOOT心灵心理健康平台(心灵治愈交流平台)(含论文)源码2023-09-27
- JAVA+SPRINGBOOT+VUE工厂车间管理系统(含论文)源码2023-09-27
- JAVA_SSM+VUE校园二手物品交易平台(含论文)源码2023-09-27
- JAVA+SSM医院住院管理系统(含论文)源码2023-09-27
- JAVA VUE SSM教材管理系统(含论文、PPT)课程设计2023-09-27
- 基于SPRINGBOOT 旅游共享平台 + 论文2023-09-26
关于我们 | 顾问团队 | 发展历程 | 联系我们 | 源码上传
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号
联系电话(Tel):4008-010-151(免长途)
地址:北京市海淀区大恒科技大厦五层 邮编:100080
Floor 5th,Daheng Building,Zhongguancun,Beijing,China,100080
51Aspx.com 版权所有 CopyRight © 2006-2023. 京ICP备09089570号 | 京公网安备11010702000869号