How to use phpspreadsheet reader with $wpdb

I’m assuming you mean this PhpSpreadsheet; if not, please edit your question to clarify.

To incorporate any third-party PHP library into your WordPress site, you’ll either need to write a plugin or find one that already does what you need.

The PhpSpreadsheet docs explain how you’d incorporate their library into any PHP application, which includes a WordPress plugin.

composer require phpoffice/phpspreadsheet
composer install

on the command line (in your plugin’s root directory) will ensure that the required library|ies are installed. Then, in the plugin’s code,


require 'vendor/autoload.php';

use PhpOffice\PhpSpreadsheet\Spreadsheet;
use PhpOffice\PhpSpreadsheet\Writer\Xlsx;

…will load the required PHP files and set you up to read and write XLSX files.

Without knowing more about how PhpSpreadsheets works, it’s hard to say much more. You’ll have to explore their documentation to see how to use their product. Note that third-party product support is off topic here.

If you’re not comfortable writing a plugin, and there’s not one already in the WP ecosystem that does what you need, you’ll have to find someone who can and will do it for you.