Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/233.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
PHP Com Excel应用过滤器_Php_Excel_Web_Ms Office - Fatal编程技术网

PHP Com Excel应用过滤器

PHP Com Excel应用过滤器,php,excel,web,ms-office,Php,Excel,Web,Ms Office,我正在用com打开excel,它工作正常,但我在同一列中同时应用两个过滤器时遇到问题。代码如下: $excel = new COM("excel.application") or die("Unable to instanciate excel"); $excel->Visible = 1; $excel->DisplayAlerts = 1; $wb = $excel->Workbooks->Open($dataFile); $sheet = $wb->Work

我正在用com打开excel,它工作正常,但我在同一列中同时应用两个过滤器时遇到问题。代码如下:

$excel = new COM("excel.application") or die("Unable to instanciate excel");
$excel->Visible = 1;
$excel->DisplayAlerts = 1;

$wb = $excel->Workbooks->Open($dataFile);
$sheet = $wb->Worksheets(1);

// apply filters
$sheet->range("AS1")->AutoFilter(45, '<>'); // works with single filter
$excel=new COM(“excel.application”)或die(“无法实例化excel”);
$excel->Visible=1;
$excel->DisplayAlerts=1;
$wb=$excel->工作簿->打开($dataFile);
$sheet=$wb->工作表(1);
//应用过滤器
$sheet->range(“AS1”)->自动筛选(45,);//适用于单过滤器
但是,当我想对同一列同时应用两个过滤器时,它不起作用:

$sheet->range("AS1")->AutoFilter(45, '<> AND > 0'); // DOES NOT WORK
$sheet->range(“AS1”)->AutoFilter(45'和>0');//不起作用
我的猜测是,我应该使用实际的excel常量
excel.XlAutoFilterOperator.xlAnd
,而不是在上面的语句中使用
作为文本字符串,但我无法获得它


任何帮助都将不胜感激

好吧,我知道了,我必须传递额外的参数:

define('xlAnd', 1);

$sheet->range("AS1")->AutoFilter(45, '<>', xlAnd, '> 0');
定义('xlAnd',1);
$sheet->range(“AS1”)->自动筛选(45',xlAnd',0');

免责声明-我不知道您正在使用的工具,也不会假装知道。话虽如此,似乎有可能切换逻辑?例如,
$sheet->range(“AS1”)->自动筛选(45'>0和')?萨姆斯威夫特说:“我假设这是因为它看起来像是介于某件事之间。”웃 谢谢,我正在使用PHP。不,那也不行:(