PHP Com Excel应用过滤器
我正在用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
$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。不,那也不行:(