Tuesday, October 13, 2015

Excel export from JSON


I have a previous posts on generating Excel file from a table. Unfortunately they do not work in IE. We can generate Excel file from a JSON file as shown below

What do we need?

  • JSONtoCSVConverter javascript file.
  • JSON Data
  • Jquery 
This line is important
 JSONToCSVConvertor(data, "Blog Report", true);

 1st parameter accepts data
 2nd parameter we specify the file name
 3rd paramter we spcecify whether we need label

    <title>Internet explorer download</title>
    <script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
    <script src="http://code.jquery.com/jquery-migrate-1.2.1.min.js"></script>
     <script src="../scripts/Excel/ExcelExport.js"></script>
    <div align="center">
        <h3><u>Enter JSON data</u></h3>
        <div class="mydiv">
                   <textarea cols="100" rows="15" class="txtarea" id="txt">[{"Blog Name":"PrathapKudupusBlog","Date":"30 Jul 2013 09:24 AM","Type":"Technical","Author"
:"Prathap Kudupu"},
{"Blog Name":"ABCBlog","Date":"30 Jul 2011 09:24 AM","Type":"Technical","Author"
{"Blog Name":"XYZBlog","Date":"30 Jul 2011 09:24 AM","Type":"Technical","Author"
span style="line-height: 18.5625px;"></textarea>
  </div> <br> <h3><u>Click below button to download <strong>CSV</strong> file for internet explorer and other browsers</u></h3> <br> <button class="download">Download CSV</button></div> </body> </html>

$(document).ready(function () {
    $('.download').click(function () {
        var data = $('#txt').val();
        if (data == '')
        JSONToCSVConvertor(data, true);



  1. doesn't work in IE. There is a limit on number of characters for URL value in IE

  2. Thanks for in the info. I wrote this article 2 years back and did not validate the size limit