2017-02-23 74 views
1

每次我試圖將內容導出我的jqGrid的的,它會失敗,並顯示以下錯誤:從我的網如何修復JqGrid exportToExcel無效的xml錯誤?

Uncaught Error: Invalid XML: <?xml version="1.0" encoding="UTF-8" standalone="yes"?><Relationships xmlns="http:?><Relationships xmlns="http://schemas.openxmlformats.org/package/2006/relationships"><Relationship Id="rId1" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/worksheet" Target="worksheets/sheet1.xml"/><Relationship Id="rId2" Type="http://schemas.openxmlformats.org/officeDocument/2006/relationships/styles" Target="styles.xml"/></Relationships> 
at Function.error (jquery-1.10.2.js:530) 
at Function.parseXML (jquery-1.10.2.js:610) 
at HTMLTableElement.<anonymous> (jquery.jqGrid.min.js:1513) 
at Function.each (jquery-1.10.2.js:671) 
at init.each (jquery-1.10.2.js:280) 
at init.exportToExcel (jquery.jqGrid.min.js:1483) 
at init.$.fn.jqGrid (jquery.jqGrid.min.js:101) 
at <anonymous>:1:22 

的數據是使用ASP.NET構建的的Web API MVC5

下面是我網格的代碼段,我的導出按鈕:

$('#myGrid').jqGrid({ 
 
     url: '/api/Remittance/GetRemittance', 
 
     mtype: 'GET', 
 
     datatype: 'json', 
 
     styleUI: 'Bootstrap', 
 
     colModel: [ 
 
      { key: true, hidden: true, label: 'Id', name: 'Id', width: 300 }, 
 
      { label: 'System Source', name: 'System_Source', width: 150 }, 
 
      { label: 'Placement Ref', name: 'Placement_Ref', width: 200 }, 
 
      { label: 'Transmittal Date', name: 'Transmittal_Date', width: 150, formatter: 'date', formatoptions: { newformat: 'm/d/Y' } }, 
 
      { label: 'Transmittal Reference', name: 'Transmittal_Reference', width: 200 }, 
 
      { label: 'Transmittal Notes', name: 'Transmittal_Notes', width: 200 }, 
 
      { label: 'Doc Transaction Id', name: 'Doc_Transaction_Id', width: 150 }, 
 
      { label: 'Doc Transaction Type', name: 'Doc_Transaction_Type', width: 170 }, 
 
      { label: 'Doc Status', name: 'Doc_Status', width: 150 }, 
 
      { label: 'Doc Date', name: 'Doc_Date', width: 150, formatter: 'date', formatoptions: { newformat: 'm/d/Y' } }, 
 
      { label: 'Doc Reference', name: 'Doc_Reference', width: 200 }, 
 
      { label: 'Doc Order Reference', name: 'Doc_Order_Reference', width: 200 }, 
 
      { label: 'Doc From', name: 'Doc_From', width: 200 }, 
 
      { label: 'Doc To', name: 'Doc_To', width: 200 }, 
 
      { label: 'Doc Sales Representative', name: 'Doc_Sales_Representative', width: 200 }, 
 
      { label: 'Doc Sales/Supply Unit', name: 'Doc_Sales_Supply_Unit', width: 200 }, 
 
      { label: 'Doc Amount', name: 'Doc_Amount', width: 150, formatter: 'currency', formatoptions: { decimalSeparator: '.', thousandsSeparator: ',', decimalPlaces: 2 } }, 
 
      { label: 'Doc Deductions', name: 'Doc_Deductions', width: 150, formatter: 'currency', formatoptions: { decimalSeparator: '.', thousandsSeparator: ',', decimalPlaces: 2 } }, 
 
      { label: 'Doc Gross Amount', name: 'Doc_Gross_Amount', width: 150, formatter: 'currency', formatoptions: { decimalSeparator: '.', thousandsSeparator: ',', decimalPlaces: 2 } } 
 
     ], 
 
     autoWidth: false, 
 
     shrinkToFit: false, 
 
     viewrecords: true, 
 
     emptyrecords: 'No records to display.', 
 
     width: $(this).parent().width(), 
 
     height: 375, 
 
     rowNum: 10, 
 
     pager: '#pagerGrid', 
 
     jsonReader: { 
 
      root: 'rows', 
 
      page: 'page', 
 
      total: 'total', 
 
      records: 'records', 
 
      Id: '0' 
 
     } 
 
     
 
     $('#exportGrid').click(function() { 
 
     var today = new Date(); 
 
     var dd = today.getDate(); 
 
     var mm = today.getMonth() + 1; 
 
     var yyyy = today.getFullYear(); 
 

 
     $('#myGrid').jqGrid('exportToExcel', { 
 
      includeLabels: true, 
 
      includeGroupHeader: true, 
 
      includeFooter: true, 
 
      fileName: 'Remittance_' + mm + '-' + dd + '-' + yyyy + '.xlsx', 
 
      maxlength: 40 
 
     }); 
 
    });

回答

0

只是使用jquery.jqGrid.js(不含min版本)。它應該工作。我的也有同樣的問題。它現在有效

+0

忘記更新,我已經解決了這個問題。你是對的,這是解決方案。 –