We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Hi I use this plugin in wordpress theme. Everything works fine. But I don't know how to download the file in Ajax.
$(document).on('click', '#export_to_excel', function (e) { e.preventDefault(); $.ajax({ url: ajax_url, type: 'post', cache: false, data: {action:'export_to_excel'}, success: function (response) { if (response.status === 'error') { } else { } } }) })
add_action('wp_ajax_export_to_excel', function () { global $wpdb; $table = $wpdb->prefix . 'custom'; $lists= $wpdb->get_results("SELECT * FROM {$table }", ARRAY_A); $data = []; foreach ($lists as $list) { $data[] = [$lists['name'], $lists['url']]; } SimpleXLSXGen::fromArray($data)->downloadAs('file.xlsx'); });
The text was updated successfully, but these errors were encountered:
Try save XLSX to public folder and return url as result. Then document.location = result.xlsx_url
document.location = result.xlsx_url
Sorry, something went wrong.
or see https://github.com/shuchkin/simplexlsxgen?tab=readme-ov-file#js-array-to-excel-ajax
No branches or pull requests
Hi
I use this plugin in wordpress theme. Everything works fine. But I don't know how to download the file in Ajax.
The text was updated successfully, but these errors were encountered: