Search code examples
gridviewexport-to-excelshieldui

SheildUI Grid SaveToExcel proxy, What is SaveData?


In your MVC SaveToExcel proxy code:

public HttpResponseMessage Save([FromBody] SaveData saveData)
{
    var data = Convert.FromBase64String(saveData.Base64Content);
    var contentType = saveData.ContentType;

    // strip the content encoding and other additional headers from the type
    contentType = Regex.Replace(contentType, ";.*$", "", RegexOptions.Compiled | RegexOptions.Multiline | RegexOptions.IgnoreCase);

    var result = new HttpResponseMessage(HttpStatusCode.OK)
    {
        Content = new StreamContent(new MemoryStream(data))
    };

    result.Content.Headers.ContentType = new MediaTypeHeaderValue(contentType);
    if (contentType.Contains("xml"))
    {
        result.Content.Headers.ContentType.CharSet = "UTF-8";
    }

    result.Content.Headers.ContentDisposition = new ContentDispositionHeaderValue("attachment")
    {
        FileName = saveData.FileName
    };

    return result;
}

In what assembly can I find the TYPE SaveData? I can find no references to it on MSDN and this is for javascript library usage, I'm not using MVC version of ShieldUI Grid control.

It would be helpful if you'd update the documentation with the answer as well.

It might be a good idea to show how to use this with remote data binding, too.


Solution

  • Seems like SaveData is a model class for the input, being sent from the browser to the file saver utility.

    After notifying the Shield UI maintenance developers earlier today, I just saw that they have updated their documentation to include the full source code.