Having trouble exporting data from Excel using react-data-export

I've been attempting to create an excel export feature, but for some unknown reason, it's not functioning properly. I'm utilizing react-data-export and followed a small test example from this GitHub link, yet the export is not working as expected.

Here is the button I have created:

 <Button 
      startIcon = {<FileDownloadIcon />} 
      variant = "contained" 
      color = "success" 
      size = "medium" 
      onClick={exporExcel} >
      Export Excel
 </Button>

And here is the function I am using:

const exporExcel = () => {
      <ExcelFile>
        <ExcelSheet data = {pedidos} name = "Prueba">
        <ExcelColumn label="# Pedido" value="id"/>
        <ExcelColumn label="Estudiante" value="nombre"/>
        <ExcelColumn label="Colegio" value="escuela"/>
        <ExcelColumn label="Grado" value="grado"/>
        </ExcelSheet>
      </ExcelFile>
  };

Answer №1

To make it work, place the button on the ExcelFile tag as shown below:

<ExcelFile element={<YourCustomButtonComponent />}>
    <ExcelSheet data = {pedidos} name = "Prueba">
    <ExcelColumn label="# Pedido" value="id"/>
    <ExcelColumn label="Estudiante" value="nombre"/>
    <ExcelColumn label="Colegio" value="escuela"/>
    <ExcelColumn label="Grado" value="grado"/>
    </ExcelSheet>
</ExcelFile>

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

Regularly updating a book's interactive pages with turn.js technology

I experimented with generating dynamic content in turn.js using the sample provided here. This is an excerpt of the code I have written: <body> <div id="paper"> </div> </body> <script type="text/javascript"> $(win ...

Issues with GitHub Pages' HTTP "Post" Request

I am currently in the process of developing my own website hosted on GitHub Pages. This website is being created using react.js and what you see here is a contact form. The issue I am facing is that I am unable to send a POST request to a Google Cloud P ...

Using Material UI date picker with TypeScript: A Complete Guide

Well, I have to admit that I usually don't resort to putting 'any' as the type when I'm uncertain what to do, but right now, I'm starting to feel quite frustrated. I'm currently working with Material UI date picker in conjunct ...

Is jQuery capable of appropriately escaping my quotes?

Currently, I am utilizing $.cookie() to retrieve all the values from a cookie which are stored in JSON format: var properties = $.cookie('params'); The output of properties is: {"distinct_id": "13f97d6600b42e-000e6293c-6b1b2e75-232800-13f97d66 ...

What is the best way to display changing session variables in PHP?

Purchase Page: This page allows customers to select business card orders in various foreign languages and customize their options. Whenever a user decides to add an extra card by clicking a button, javaScript dynamically includes new form fields. To ensur ...

A sleek and streamlined scrollspy that dynamically updates the active class exclusively for anchor tags

Can anyone help me with this coding problem? I'm currently working on a minimalistic scrollspy code that adds an active class when the content is offset.top. The code works fine, but I want to change the active class to apply to the "a" tag instead of ...

Troubleshooting the issue with reactdom.render() functionality in CodeSandbox

Having issues with ReactDom in CodeSandbox for React. The HTML file includes: <body> <div id="root"></div> </body> <script src="scr/index.js"> The JavaScript file (named index) includes: ReactDOM.rende ...

Solving the issue of 'b-modal' not appearing in a Vue.js custom component

Software Used: Vue.js Bootstrap-Vue () Issue: My aim is to show a popup when a row is clicked within a bootstrap grid. Once the modal is closed, I want it to disappear and the selected item to be removed. To tackle this problem, I have developed a custo ...

JavaScript hovering drop-down feature

Hi there, I'm just starting out with javascript and could use some help with a simple script. I have a shopping cart drop down that currently activates when clicked. However, I want it to fade in when hovered over instead. I've tried using .hove ...

When the form is submitted, use jQuery to smoothly transition the page to a specific

I have a form and a div called "success". When the form is submitted, the "success" div is displayed. I am attempting to make it so that when the form is submitted, the page slides to the "success" div. Here is the code I am using: $.ajax({ type: "P ...

Using the Mousetrap binding on a nuxt.js page may not be effective

Hey there! I'm trying to achieve a certain functionality where I want to redirect to a different page once a specific sequence is typed. Although I can see the message "It works" in my console, the redirection is not happening and instead, I am gettin ...

JQuery clockpicker failing to fire change event for input field

While working on a codebase, I encountered a callback binding scenario where a specific action needs to take place whenever any input is altered. $(document.body).on('change', '.input-sm', function (){ ... }) The challenge arises whe ...

Adjust the browser zoom level to default when navigating to a new page

My mobile site uses ajax to load pages, and I'm looking to implement a feature that resets the zoom level when a page changes. Is there an effective way to detect if a user has zoomed the view while browsing a page? Currently, I have been able to ch ...

Modify the background color of a pseudo-element's property value dynamically

How do I change the background color of my burger menu by clicking on an icon? This is the CSS code I have: :root{ --pseudo-backgroundcolor: yellow; } .menu__icon span, .menu__icon::before, .menu__icon::after{ background: va ...

I'm attempting to build a React app using the command (create-react-app app-name), however, I keep encountering an error. Can anyone shed some light on why this

Despite trying to clear the cache, my problem persists. It was functioning properly just a few hours ago, until I used npm run eject on another project. Since then, I have been encountering this error. I will include an error file along with the log. Can a ...

Tips for enforcing validation rules at the class level using Angular's version of jQuery Validate

After utilizing jQuery Validate's convenient addClassRules function to impose a rule on all elements of a specific class, rather than relying on the attributes of their name, I encountered a roadblock when trying to do the same with the Angular wrappe ...

Can cucumber steps be executed conditionally within a single scenario?

I would like to streamline my testing process by using one feature file for both desktop and mobile tests. I am looking to run two separate tests, with one tagged as @mobile and the other as @desktop. By doing this, I can avoid creating a duplicate feature ...

Avoiding the default action to submit AJAX form data won't result in any changes to the front end?

Currently, I am working with Flask and have utilized JavaScript to prevent default behavior in order to send all the necessary data through an AJAX request. However, I am facing an issue where although my view contains all the data (verified by console out ...

Dependency of multiple objects in Webgl three.js

I'm struggling with object dependencies and need help. I want to create a setup where one object is dependent on two other objects. Essentially, when I modify the position of one parent object (like changing the y-Position), the dependent object (chil ...

OpenLayers: real-time data display of objects from a list

When working with OpenLayers, I encountered an issue where my object was undefined and I couldn't retrieve the information I needed to display feature data on the map. Initially, I passed a list from the controller to my JSP file and attempted to use ...