VLOOKUP在PHPSpreadsheet中返回#N / A.
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了VLOOKUP在PHPSpreadsheet中返回#N / A.相关的知识,希望对你有一定的参考价值。
我正在尝试使用phpspreadsheet在excel文件中实现的计算器。使用多张纸。第一张纸有计算器本身。
我是否正确地将价值观放在其中?
$spreadsheet = PhpOfficePhpSpreadsheetIOFactory::load('calc.xlsx');
$worksheet = $spreadsheet->setActiveSheetIndex(0);
$worksheet->setCellValue('D8', 210000);
$worksheet->setCellValue('D9', 160000);
$worksheet->setCellValue('D10', '5%');
$worksheet->setCellValue('D11', 30);
$worksheet->setCellValue('D12', -1073);
$worksheet->setCellValue('D15', 50000);
$worksheet->setCellValue('D16', '7%');
$worksheet->setCellValue('D19', 5000);
$worksheet->setCellValue('D20', 5000);
$worksheet->setCellValue('D21', 4500);
$worksheet->setCellValue('D24', '12/7/2018');
因为下面的代码输出#N / A.
$worksheet->setCellValue('I8', '=VLOOKUP("L",Daily!A:N,3,FALSE)');
echo $worksheet->getCell('I8')->getFormattedValue();
试图在wordpress插件中执行此操作。
答案
VLOOKUP公式中名为“每日”的工作表上有什么?我使用相同的代码,并在Sheet 1上生成以下内容:
我还把我在“每日”表上的内容用于测试目的。
$path = 'c:/xxx/xxx/desktop/TestDoc.xlsx';
$spreadsheet = PhpOfficePhpSpreadsheetIOFactory::load($path);
$worksheet = $spreadsheet->setActiveSheetIndex(0);
$worksheet->setCellValue('D8', 210000);
$worksheet->setCellValue('D9', 160000);
$worksheet->setCellValue('D10', '5%');
$worksheet->setCellValue('D11', 30);
$worksheet->setCellValue('D12', -1073);
$worksheet->setCellValue('D15', 50000);
$worksheet->setCellValue('D16', '7%');
$worksheet->setCellValue('D19', 5000);
$worksheet->setCellValue('D20', 5000);
$worksheet->setCellValue('D21', 4500);
$worksheet->setCellValue('D24', '12/7/2018');
$worksheet->setCellValue('I8', '=VLOOKUP("L",Daily!A:N,3,FALSE)');
echo $worksheet->getCell('I8')->getFormattedValue();
$writer = PhpOfficePhpSpreadsheetIOFactory::createWriter($spreadsheet, "Xlsx");
$writer->save('c:/xxx/xxx/desktop/TestDoc.xlsx');
以上是关于VLOOKUP在PHPSpreadsheet中返回#N / A.的主要内容,如果未能解决你的问题,请参考以下文章