我正在使用PHPExcel来读取xls文件,这是我的代码:
require('PHPExcel/PHPExcel.php');
$Reader = PHPExcel_IOFactory::createReaderForFile($xls_path);
$Reader->setReadDataOnly(true);
$objXLS = $Reader->load($xls_path);
$data = $objXLS->getActiveSheet()->toArray(null, true, true, true);
$objXLS->disconnectWorksheets();
unset($objXLS);
var_dump($data);
输出是:
Array
(
[A] => 1001
[B] => XXX
[C] => AAZ878
[D] => 19233
[E] => pppp
[F] => oooo
[G] => 276
[H] => Y
)
如何在我的代码中指定只读取列A,B和H,以便输出
Array
(
[A] => 1001
[B] => XXX
[H] => Y
)
由于
答案 0 :(得分:1)
您不能使用Promise.join(
Foo.findOne({
bar: 'baz'
}),
Player.findById(userId),
function(foo, player) {
console.log(foo, bar);
});
;但是你可以轻松地做一个array_walk(),它带有一个回调,可以将每个子数组修改为你想要的那些列。类似的东西:
toArray()