Hi,

BACKGROUND

I am developing a C++ program that retrieves the desired data from a website and exports it to Excel. This "Export to Excel" part of this task is what is giving me trouble. To perform this manually, I have to click a javascript button which triggers a certain OnClick event.


I have been using libcurl to mimick the POST and GET requests to retrieve the data. I tried to write the retrieved data to an Excel file, instead of trying to "click" the Export to Excel button programmatically and partially succeeded. There are pages and pages of data, and only the first page is written to the Excel file by doing it this way.

What I need to figure out is how to programmatically click this "Export to Excel" button.


HTML SOURCE CODE

Code:
<!-- clientExportButton calls hiddenexportButton through ExportGrid JS method as workaround for 'wait' cursor issue on export -->


<input id="clientExportButton" type="button" value="Export" onclick="ExportGrid('ctl02_G2_4_3_100003423_0_0_0_1_runtimeWebGrid','ctl02_G2_4_3_100003423_0_0_0_1_hiddenexportButton','ctl02_G2_4_3_100003423_0_0_0_1_outputFilterDropDownlist','50000','')" style="cursor: wait;">



<input type="submit" name="ctl02$G2$4_3_100003423_0_0_0_1$hiddenexportButton" value="Export Hidden" id="ctl02_G2_4_3_100003423_0_0_0_1_hiddenexportButton" style="visibility:hidden">


JAVASCRIPT FUNCTION

Code:
function ExportGrid(runtimeWebGridClientID, hiddenexportButtonClientID, outputFilterDropDownlistClientID, maxExportRowCount, message) {

    var filter = document.getElementById(outputFilterDropDownlistClientID);
    if (filter.value != "SELECTED" && message != "") {

        if (filter.value == "PAGE") {
            var grid = igtbl_getGridById(runtimeWebGridClientID);
            if (grid.Rows.length > maxExportRowCount) {
                alert(message);
            }
        }
        else {
            alert(message);
        }
    }

    document.getElementById(hiddenexportButtonClientID).click();

    if (typeof (EnableForm) != "undefined") {
        EnableForm();
    }
}

What is the best/easiest way to trigger a Javascript OnClick event in C++?-capture-png

What is the best/easiest way to trigger a Javascript OnClick event in C++?-capture2-jpg

I have researched V8, SpiderMonkey, PhantomJS, Node.JS. What is/ which of these is the easiest, most appropriate way to accomplish what I want to do from my C++ program, and how do I use it in combination with libcurl?