admin管理员组

文章数量:1122846

I am trying to import an excel file on a webpage with a submit button. As far as I can tell, the only way to do so is to use PhpSpreadsheet. How can one incorporate PhpSpreadsheet with $wpdb and wordpress?

I am trying to import an excel file on a webpage with a submit button. As far as I can tell, the only way to do so is to use PhpSpreadsheet. How can one incorporate PhpSpreadsheet with $wpdb and wordpress?

Share Improve this question asked May 18, 2023 at 16:36 John LyonsJohn Lyons 314 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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,

<?php

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.

本文标签: phpHow to use phpspreadsheet reader with wpdb