Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>If you can generate the Excel file on the server, that is probably the best way. With Excel you can add formatting and get the output to look better. Several Excel options have already been mentioned. If you have a PHP backend, you might consider <a href="https://github.com/PHPOffice/PHPExcel" rel="noreferrer">phpExcel</a>.</p> <p>If you are trying to do everything on the client in javascript, I don't think Excel is an option. You could create a CSV file and create a data URL to allow the user to download it.</p> <p>I created a JSFiddle to demonstrate: <a href="http://jsfiddle.net/5KRf6/3/" rel="noreferrer">http://jsfiddle.net/5KRf6/3/</a></p> <p>This javascript (assuming you are using jQuery) will take the values out of input boxes in a table and build a CSV formatted string:</p> <pre><code>var csv = ""; $("table").find("tr").each(function () { var sep = ""; $(this).find("input").each(function () { csv += sep + $(this).val(); sep = ","; }); csv += "\n"; }); </code></pre> <p>If you wish, you can drop the data into a tag on the page (in my case a tag with an id of "csv"):</p> <pre><code>$("#csv").text(csv); </code></pre> <p>You can generate a URL to that text with this code:</p> <pre><code>window.URL = window.URL || window.webkiURL; var blob = new Blob([csv]); var blobURL = window.URL.createObjectURL(blob); </code></pre> <p>Finally, this will add a link to download that data:</p> <pre><code>$("#downloadLink").html(""); $("&lt;a&gt;&lt;/a&gt;"). attr("href", blobURL). attr("download", "data.csv"). text("Download Data"). appendTo('#downloadLink'); </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload