- Home
- Forum
- ASP.NET Web Forms
- Exporting to Excel, Word, PDF Error
Exporting to Excel, Word, PDF Error
I following the document on https://help.syncfusion.com/aspnet/grid/exporting
Attachment: example_code_af96aee2.rar
everything seem no problem on code, but when I clicked the export button the IIS express on VS2017 show an error like below
please help me ~ ~
HTTP Error 405.0 - Method Not Allowed
The page you are looking for cannot be displayed because an invalid method (HTTP verb) is being used.
Most likely causes:
Things you can try:
Detailed Error Information:
Attachment: example_code_af96aee2.rar
SIGN IN To post a reply.
1 Reply
VN
Vignesh Natarajan
Syncfusion Team
February 1, 2019 07:40 AM UTC
Hi sengdala,
Thanks for contacting Syncfusion support.
Query: Exporting to Excel, Word, PDF Error
From your query, we understand that you need to export the Grid data to excel format. From the shared sample, we could see that you have not defined the Export functions in the controller page. Due to this the reported issue will occur.
To export the Grid, server side must be configured using any of the available web services, since you have use webAPI controller. We suggest you to refer the below UG documentation how to configure the WebAPi controller for exporting
For your convenience we have modified the provided sample, please refer the below code and sample link,
|
var dm = ej.DataManager({
url: "/api/Orders/GetOrders",
adaptor: new ej.UrlAdaptor(),
enableCaching: false,
cachingPageSize: 10,
timeTillExpiration: 120000
});
$("#Grid1").ejGrid({
dataSource: dm,
……………..
toolbarSettings: {
showToolbar: true, toolbarItems: ['search', ej.Grid.ToolBarItems.ExcelExport, ej.Grid.ToolBarItems.WordExport, ej.Grid.ToolBarItems.PdfExport]
},
toolbarClick: function (args) {
if (args.itemName == "Excel Export") {
this.export("/api/Orders/ExcelExport");
args.cancel = true;
}
else if (args.itemName == "Word Export") {
this.export("/api/Orders/WordExport");
args.cancel = true;
}
else if (args.itemName == "PDF Export") {
this.export("/api/Orders/PdfExport");
args.cancel = true;
}
},
columns: [
……………..
]
});
</script>
Controller Page
<ActionName("ExcelExport")>
<HttpPost>
Public Sub ExcelExport()
Dim exp As ExcelExport = New ExcelExport()
Dim gridModel As String = HttpContext.Current.Request.Params("GridModel")
Dim obj As GridProperties = CType(Syncfusion.JavaScript.Utils.DeserializeToModel(GetType(GridProperties), gridModel), GridProperties)
Dim Db As NORTHWNDEntities = New NORTHWNDEntities()
Dim result = Db.Orders.ToList()
Dim excelExp As GridExcelExport = New GridExcelExport()
excelExp.FileName = "Export.xlsx"
excelExp.Excelversion = ExcelVersion.Excel2010
excelExp.Theme = "flat-saffron"
exp.Export(obj, result, excelExp)
End Sub
<ActionName("WordExport")>
<HttpPost>
Public Sub WordExport()
Dim exp As WordExport = New WordExport()
Dim gridModel As String = HttpContext.Current.Request.Params("GridModel")
Dim obj As GridProperties = CType(Syncfusion.JavaScript.Utils.DeserializeToModel(GetType(GridProperties), gridModel), GridProperties)
Dim Db As NORTHWNDEntities = New NORTHWNDEntities()
Dim result = Db.Orders.ToList()
Dim WordExp As GridWordExport = New GridWordExport()
WordExp.FileName = "Export.docx"
WordExp.Theme = "flat-saffron"
exp.Export(obj, result, WordExp)
End Sub
<ActionName("PdfExport")>
<HttpPost>
Public Sub PdfExport()
Dim exp As PdfExport = New PdfExport()
Dim gridModel As String = HttpContext.Current.Request.Params("GridModel")
Dim obj As GridProperties = CType(Syncfusion.JavaScript.Utils.DeserializeToModel(GetType(GridProperties), gridModel), GridProperties)
Dim Db As NORTHWNDEntities = New NORTHWNDEntities()
Dim result = Db.Orders.ToList()
Dim PdfExp As GridPdfExport = New GridPdfExport()
PdfExp.FileName = "Export.pdf"
PdfExp.Theme = "flat-saffron"
exp.Export(obj, result, PdfExp)
End Sub
|
For your convenience we have attached the sample which can be downloaded from below link
Sample Link: http://www.syncfusion.com/downloads/support/forum/142391/ze/WebApplication4_2ecd5122673400336
Please get back to us if you have further queries.
Regards,
Manivannan Padmanaban.
SIGN IN To post a reply.
- 1 Reply
- 2 Participants
-
SE sengdala
- Jan 31, 2019 09:58 AM UTC
- Feb 1, 2019 07:40 AM UTC