I've got a grid which is populated from an external API, which displays on screen fine. I'm trying to activate the button to export this to Excel.
problem 1 : When the export button is clicked, it tries to redirect to a page /ExportToExcel instead of the url /Invoice/ExportToExcel
problem 2 : the ExportToExcel function example you give on your website is in c#, I've tried writing it in VB but i'm getting 'Syncfusion.gridexcelconverter' and 'GridProperties' as known objects
problem 3 : the datasource appears to link directly back to the database - I can't do that; I pass the API's results to the form via a viewbag, but I can run the API query again if necessary in the controller, as long as I have a way of passing the details through.
controller imports :
Imports System.Web.Mvc
Imports System.Net
Imports Syncfusion.EJ.export
Imports Syncfusion.EJ
Imports Syncfusion.Linq
Imports Syncfusion.Compression
Imports Syncfusion.XlsIO
controller exporttoexcel function
Function ExportToExcel( GridModel as string )
Dim gecc = New Syncfusion.gridexcelconverter
dim exp = new ExcelExport()
Dim DataSource = new NorthwindDataContext().OrdersViews.ToList()
dim obj =Syncfusion.JavaScript.Utils.DeserializeToModel(typeof(GridProperties), GridModel)
exp.Export(obj, DataSource, "Export.xlsx", ExcelVersion.Excel2010, false, false, "flat-saffron")
End Function
and on the page grid
Dim gridbuilder = Html.EJ().Grid(Of NFSInvoiceHeader)("InvoiceGrid")
gridbuilder.Datasource(ViewBag.InvoiceList)
gridbuilder.ToolbarSettings( Sub (toolBar) toolBar.ShowToolbar().ToolbarItems (
Sub (items)
items.AddTool(ToolBarItems.ExcelExport )
End Sub))
gridbuilder.Columns(
Sub(col)
col.Field("invDate").Format("{0:dd/MM/yyyy}").HeaderText("Date").Width(10).Add()
col.Field("invNumber").HeaderText("Number").Width(20).Add()
col.Field("invNet").HeaderText("Net").Width(20).Add()
'col.Field("invVAT").HeaderText("VAT").Width(30).Add()
'col.Field("invGross").HeaderText("Gross").Width(20).Add()
col.Field("invNumber").HeaderText("View").Width(20).Add()
End Sub)
gridbuilder.AllowGrouping()
gridbuilder.AllowSorting()
gridbuilder.Render()
gridbuilder.AllowPaging()
Can anyone point me in the right direction?
thanks