locked
export to excel RRS feed

  • Question

  • Hi all.

    Does anyone know how to export to excel via c#? I would like to export with the availability to import.

    Thanks!

    Thursday, March 29, 2012 8:16 PM

Answers

  • Hi, 

    There is no supported/documented SDK API, but if you are using an On-Prem deployment you can make a POST request to :

    http://server:port/orgname/_grid/print/print_data.aspx

    Posting the following values:

    • fetchXml=<fetchxml>
    • gridXml=<layoutxml>
    • printAllPages=0
    • reimport=1

    hth,

    Scott


    Scott Durow
    Read my blog: www.develop1.net/public
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"


    Thursday, March 29, 2012 9:00 PM
    Answerer

All replies

  • Hi, 

    There is no supported/documented SDK API, but if you are using an On-Prem deployment you can make a POST request to :

    http://server:port/orgname/_grid/print/print_data.aspx

    Posting the following values:

    • fetchXml=<fetchxml>
    • gridXml=<layoutxml>
    • printAllPages=0
    • reimport=1

    hth,

    Scott


    Scott Durow
    Read my blog: www.develop1.net/public
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"


    Thursday, March 29, 2012 9:00 PM
    Answerer
  • Thanks Scott

    That is what I have found so far.

    Thursday, March 29, 2012 9:02 PM
  • Hi Scott,

    I tried the below post method, and returned me an error as this action is unsupported.

    Please check

    if (IsNull(_oCrmGrid.InnerGrid))
                    return;
                
                var http = new XMLHttpRequest();
                var url = prependOrgName("/_grid/print/print_data.aspx");
                var fetchxml=document.getElementById("FetchXml").value;
                var layoutxml = document.getElementById("LayoutXml").value;
                var params = "lorem=ipsum&fetchXml="+fetchxml +"&gridXml="+layoutxml+"&printAllPages=0&reimport=1";
                http.open("POST", url, true);
    
                //Send the proper header information along with the request
                http.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
                http.setRequestHeader("Content-length", params.length);
                http.setRequestHeader("Connection", "close");
    
                http.onreadystatechange = function () {//Call a function when the state changes.
                    if (http.readyState == 4 && http.status == 200) {
                        alert(http.responseText);
                    }
                }
                http.send(params);
            }  
    

    Regards,

    Shivam CRM

    Thursday, August 2, 2012 6:55 AM