title: How to upload and read .csv, .xls and .xlsx in React
body: <p>I'm trying to upload a file with the format of <code>.csv/.xls/.xlsx</code> and then read the file contents.</p>
  
  <p>For example the following file</p>
  
  <p><a href="https://i.stack.imgur.com/SWfDS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SWfDS.png" alt="enter image description here"></a></p>
  
  <p>would output:  </p>
  
  <pre><code>name,age,key  
  Mark,25,1  
  Jones,30,2
  </code></pre>
  
  <p>This is what I've implemented so far using <a href="https://www.npmjs.com/package/react-file-reader" rel="nofollow noreferrer">react-file-reader</a> and <a href="https://www.npmjs.com/package/base-64" rel="nofollow noreferrer">base-62</a> but it only works for the <code>.csv</code> files:  </p>
  
  <pre><code>  onFileUpload(file) {
      var decodedData = base64.decode(file.base64);
    }
  
    &lt;ReactFileReader fileTypes={[".csv",".xls", ".xlsx"]} base64={true} multipleFiles={false} handleFiles={this.onFileUpload}&gt;
      &lt;button className='btn'&gt;Upload&lt;/button&gt;
    &lt;/ReactFileReader&gt;
  </code></pre>
  
  <p>Is there any way I can get the content of <code>.xls</code> and <code>.xlsx</code> files using the same way as I did for <code>.csv</code> files? Or maybe another module that does this...</p>