ashishd751 / react-excel-renderer

A react library to render and display excel sheets on webpage
MIT License
173 stars 53 forks source link

Can I use backend api call #27

Closed TEJESH closed 3 years ago

TEJESH commented 3 years ago

I am implementing something like, after clicking on button, I am fetching excel file from backend, and it is giving me backend url for excel file. Now I want to render this file. In your example, it is taking input file, I tried to do from my side, but I am not able to. How to access api call result (excel file) and then render like you did in example.

code onclick button is something like:

openFileBrowser = () => {

      axios({
        url:'http://127.0.0.1:5000/display',
        method:'GET',
        responseType: 'blob'
      })
      .then((response) => {
          const url = window.URL
          .createObjectURL(new Blob([response.data]));
                  const link = document.createElement('a');
                  link.href = url;
                  console.log(link);
                  link.setAttribute('type', 'file');

                  document.body.appendChild(link);
                  link.click();
    })
    }
TEJESH commented 3 years ago

https://stackoverflow.com/a/67510790/1634134