menu

arrow_back How to output the data from the Exel table in the frontend WordPress?

by
1 vote
There is an exel table with data, and needed to display the data from the table on the frontend wordpress. How to implement this? Or how to use google table and pull data from there. The data will be numbers.

2 Answers

by
1 vote
There is a light library SimpleXLSX . Basic use, in the $sheetData variable you get an array from the table:

$fileImport = get_stylesheet_directory() . '/data/example.xlsx';
if ( $xlsx = SimpleXLSX::parse( $fileImport )) {
$sheetData = $xlsx->rows(1);

foreach ( $sheetData as $key => $sheetRow ) {
var_dump( $sheetRow );
}

} else {
var_dump( SimpleXLSX::parse_error() );
}
Another example here Used to use the old library PHPExcel , converts excel to and from an array, but it has been unsupported for a long time and is prone to errors on the latest versions of php
by
2 votes