Вот мой код, который я скопировал из документации PHPExcel.Я пытаюсь прочитать конкретные значения ячейки.Мы будем благодарны за любую помощь.
<?php
$inputFileType = 'Excel2007';
$inputFileName = 'cohort1.xlsx';
$sheetname = 'Sheet1';
/** Define a Read Filter class implementing PHPExcel_Reader_IReadFilter */
class MyReadFilter implements PHPExcel_Reader_IReadFilter
{
public function readCell($column, $row, $worksheetName = 'Sheet1') {
// Read rows 1 to 7 and columns A to E only
if ($row >= 1 && $row <= 7) {
if (in_array($column,range('A','E'))) {
return true;
}
}
return false;
}
}
/** Create an Instance of our Read Filter **/
$filterSubset = new MyReadFilter();
/** Create a new Reader of the type defined in $inputFileType **/
$objReader = PHPExcel_IOFactory::createReader($inputFileType);
/** Tell the Reader that we want to use the Read Filter **/
$objReader->setReadFilter($filterSubset);
/** Load only the rows and columns that match our filter to PHPExcel **/
$objPHPExcel = $objReader->load($inputFileName);
?>
У меня есть файл Excel, который я хочу прочитать с помощью PHP.Это довольно большая таблица, поэтому я решил использовать Excel вместо таблиц базы данных.
Я также хотел бы знать, есть ли другой лучший способ сделать это.Спасибо.