API
Version 7.x > API > Export to Excel, CSV, XML via API Error View modes: 
User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/20/2013 11:18:02 AM
   
Export to Excel, CSV, XML via API Error
I've got a simple method that takes a parameter and provides an exported list of transactions. Was working prior to today without issue. Now I'm getting the error below.
Code snippet
    private void ExportData(DataExportFormatEnum format)
{
DataSet ds = MyProvider.GetAllTransactions(StartDate, EndDate).DataSetResults;
DataExportHelper eh = new DataExportHelper(ds);
eh.ExportData(format, Page.Response);
}

Error
Unhandled exception at line 2, column 15475 in https://localhost/ScriptResource.axd?d=uM0OOY_47oQA-5btbQAkdNLjr-S8YPzj4jtv5h_qbMAkLCXH_CrOucoxdplx3yZ_zbR2Mw53Hfcg8KARcQ9A5bVoiGsTyO-oL9gst3GioxwF5hfTgl4NpxippoQ1&t=3a1336b1

0x800a139e - Microsoft JScript runtime error: Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.

Details: Error parsing near 'PK
Any reasons why this might be coming up?

User avatar
Kentico Support
Kentico Support
Accepted solutionAccepted solution
kentico_jurajo - 8/21/2013 1:10:05 AM
   
RE:Export to Excel, CSV, XML via API Error
Hi,

What was changed recently that could have caused this failure?
How exactly is the export working - is it in some web part, control? Are you using postback or update panel for the export action?

Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/21/2013 7:17:56 AM
   
RE:Export to Excel, CSV, XML via API Error
Ahh yes. I forgot they were changed to use an AJAX Panel. Once I unchecked that, the process worked as expected. Any suggestions as to how to get that to work and still leave AJAX in place?

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/22/2013 2:50:47 AM
   
RE:Export to Excel, CSV, XML via API Error
Hi,

If it was working before, we need to find what was changed that broke it. Would it be possible to post here more details about the code you are using and where it is used exactly?

Thank you.

Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Accepted solutionAccepted solution
Brenden Kehren - 8/22/2013 11:43:31 AM
   
RE:Export to Excel, CSV, XML via API Error
All I did was created a simple webpart with a unigrid, a few text boxes (search/filter abilities) and 3 link buttons. The 3 link buttons were the ones causing the problems. Within the webpart properties on the page template I simply checked Use Update Panel. The code for the link buttons is as follows
protected void btnExportExcel_Click(object sender, EventArgs e)
{
ExportData(DataExportFormatEnum.XLSX);
}

protected void btnExportCsv_Click(object sender, EventArgs e)
{
ExportData(DataExportFormatEnum.CSV);
}

protected void btnExportXml_Click(object sender, EventArgs e)
{
ExportData(DataExportFormatEnum.XML);
}

private void ExportData(DataExportFormatEnum format)
{
DataSet ds = MyProvider.GetAllTransactions(StartDate, EndDate).DataSetResults;
DataExportHelper eh = new DataExportHelper(ds);
eh.ExportData(format, Page.Response);
}
Once I unchecked the Use Update Panel within the webpart properties, my code behind worked fine.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/23/2013 5:36:13 AM
   
RE:Export to Excel, CSV, XML via API Error
Thank you, what happens if you set the update panel usage for some parent element/control that is surrounding the link buttons?

Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/23/2013 7:42:49 AM
   
RE:Export to Excel, CSV, XML via API Error
I did do just that. The Use update panel was checked on the webpart zone. I tried with both the webpart and the zone and neither worked. I didn't, however, get into the control to set it there, which I'm positive would work just fine.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/26/2013 6:29:19 AM
   
RE:Export to Excel, CSV, XML via API Error
Hi,

Any updates on this? Also, when using FireBug - what is the exact error? Looking at the first error message again it looks like a zip file is going there directly - the "PK". It looks like the update panel request syntax is missing and then Ajax does not know what to do with the zip file directly.

Best regards,
Juraj Ondrus

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 8/26/2013 8:09:30 AM
   
RE:Export to Excel, CSV, XML via API Error
"PK" is the start of a column name. I could click the export button a million times and the "PK" value would change to something different in the dataset, but most likely fails on the rendering of the column names.

User avatar
Kentico Support
Kentico Support
kentico_jurajo - 8/30/2013 2:12:41 AM
   
RE:Export to Excel, CSV, XML via API Error
Hi,

Would it be possible to send us your web part code files so we can inspect this issue (support@kentico.com)?

Thank you.

Best regards,
Juraj Ondrus

User avatar
Member
Member
ramon.almarza-emtmadrid - 12/20/2013 6:25:24 AM
   
RE:Export to Excel, CSV, XML via API Error
Hi, I have exactly the same problem. When I checked the Use Update Panel property of the webpart, the export funcionalllity doesn´t work. But if I don´t check this property, works without problem.

Have you any idea to solve that??

Thanks in advance.