How to Convert Excel to CSV in jQuery for Excel to CSV API in JavaScript and PDF.co Web API

Learn to Convert Excel to CSV in jQuery to Have Excel to CSV API in JavaScript

Here you may find thousands of pre-made source code pieces for easy implementation in your own programming projects. Excel to CSV API in JavaScript can be implemented with PDF.co Web API. PDF.co Web API is the Rest API that provides set of data extraction functions, and tools for document manipulation, splitting and merging of pdf files. Includes built-in OCR, and image recognition that can generate and read barcodes from images, scans, and pdf.

This rich sample source code in JavaScript for PDF.co Web API includes the number of functions and options you should do calling the API to implement excel to CSV API. This JavaScript sample code should be copied and pasted into your project. After doing this compile your project and click Run. Test JavaScript sample code examples to see whether they respond to your needs and requirements for the project.

Our website provides a free trial version of PDF.co Web API that includes source code samples to help with your JavaScript project.

On-demand (REST Web API) version:
 Web API (on-demand version)

On-premise offline SDK for Windows:
 60 Day Free Trial (on-premise)

converter.js

$(document).ready(function () {
    $("#resultBlock").hide();
    $("#errorBlock").hide();
    $("#result").attr("href", '').html('');
});

$(document).on("click", "#submit", function () {
    $("#resultBlock").hide();
    $("#errorBlock").hide();
    $("#inlineOutput").text(''); // inline output div
    $("#status").text(''); // status div

    var apiKey = $("#apiKey").val().trim(); //Get your API key at https://app.pdf.co

    var formData = $("#form input[type=file]")[0].files[0]; // file to upload
    var toType = $("#convertType").val(); // output type
    var isInline = $("#outputType").val() == "inline"; // if we need output as inline content or link to output file

    $("#status").html('Requesting presigned url for upload... &nbsp;&nbsp;&nbsp; <img src="ajax-loader.gif" />');
    $.ajax({
        url: 'https://api.pdf.co/v1/file/upload/get-presigned-url?name=test.pdf&encrypt=true',
        type: 'GET',
        headers: { 'x-api-key': apiKey }, // passing our api key
        success: function (result) {

            if (result['error'] === false) {
                var presignedUrl = result['presignedUrl']; // reading provided presigned url to put our content into
                var accessUrl = result['url']; // reading output url that will indicate uploaded file

                $("#status").html('Uploading... &nbsp;&nbsp;&nbsp; <img src="ajax-loader.gif" />');

                $.ajax({
                    url: presignedUrl, // no api key is required to upload file
                    type: 'PUT',
                    data: formData,
                    processData: false,
                    success: function (result) {

                        $("#status").html('Processing... &nbsp;&nbsp;&nbsp; <img src="ajax-loader.gif" />');

                        $.ajax({
                            url: 'https://api.pdf.co/v1/xls/convert/to/' + toType,
                            type: 'POST',
                            data: {url: accessUrl, encrypt: true, inline: isInline},
                            headers: {'x-api-key': apiKey},
                            success: function (result) {

                                $("#status").text('done converting.');

                                // console.log(JSON.stringify(result));

                                $("#resultBlock").show();

                                if (isInline) {
                                    $("#inlineOutput").text(result['body']);
                                }
                                else {
                                    $("#result").attr("href", result['url']).html(result['url']);
                                }

                            }
                        });


                    },
                    error: function () {
                        $("#status").text('error');
                    }
                });


            }
        }
    });
});



    

VIDEO

ON-PREMISE OFFLINE SDK

Get 60 Day Free Trial

See also:

ON-DEMAND REST WEB API

Get Your API Key

See also: