Edit this page

Convert an XLSX File to JSON without Using a Spreadsheet Widget

Environment

Product Progress Kendo UI Spreadsheet

Description

How can I convert an XLSX file to JSON without initializing a Spreadsheet widget?

Solution

Use a kendo.spreadsheet.Workbook object.

<div>
  1. Click to load an .xlsx file
  <input type="file" name="files" id="fileForUpload" accept=".xlsx" />
</div>
<br/>
<div>
  2. Click to print the file JSON on the console
  <input type="button" value="Click tо read file" id="btn" />
</div>

<script>
  $('#btn').on('click', function() {
    var file = document.getElementById("fileForUpload").files[0];

    if (file) {
      var workbook = new kendo.spreadsheet.Workbook({});

      workbook.fromFile(file).then(function(){
        var jsonContent = workbook.toJSON();
        console.log(jsonContent);
      })
    }
  });
</script>

See Also

Is this article helpful? Yes / No
Thank you for your feedback!

Give article feedback

Tell us how we can improve this article

close
Dummy