How to render the ASP.NET MVC Spreadsheet control in the ASP.NET MVC Visual Basic?
This article explains how to render the ASP.NET MVC Spreadsheet control in the ASP.NET MVC Visual Basic.
This article is divided into three sections:
- Creating ASP.NET MVC Application.
- Adding Spreadsheet control in ASP.NET MVC Application.
- Adding Import and Export functionalities.
Prerequisites
- Visual Studio.
- Visual Basic (To be installed in Visual Studio).
- .Net Framework 4.5 or above.
- ASP.NET MVC 4 or 5.
Creating ASP.NET MVC Application
Step 1: Open Visual studio.
Step 2: Click File -- New -- Project.
Step 3: After clicking the project, it will show the project template. Then, select the language as Visual Basic, the platform as Windows, and the project type as Web. From the listed project template, choose ASP.NET Web Application and click Next.
Step 4: After clicking Next, it will show another popup to configure your project. Provide your project name and choose the path where the project is to be created. Select the required framework and click Create.
Step 5: After clicking Create, it will show another popup to select the web application template. Select the MVC template.
Step 6: The ASP.NET MVC Application will be created successfully after clicking Create.
Adding Spreadsheet control in the ASP.NET MVC Application
Step 1: Expand the project and right-click on References. Select Manage NuGet Packages from the popup displayed.
Step 2: Search Syncfusion.EJ2.MVC5 NuGet package in the browse tab. Find the respective NuGet, select it, and install it.
Step 3: Search Syncfusion.EJ2.Spreadsheet.AspNet.MVC5 NuGet package in the browse tab. Find the respective NuGet, select it, and install it.
Step 4: After successfully installing NuGet packages, it will automatically add the required assembly reference in the Web.config file.
Step 5: Add the Stylesheet and Script reference in the <head> of ~/Views/Shared/_Layout.vbhtml.
Step 6: Register the Syncfusion Script Manager EJS().ScriptManager() at the end of the <body> of the ~/Views/Shared/_Layout.vbhtml.
Step 7: Now, add the ASP.Net MVC Spreadsheet control in the ~/Views/Home/Index.vbhtml.
Step 8: Press F5 to run the application. Find the output as follows.
Output:
Adding Import and Export functionalities
Add the import and export functionalities to the spreadsheet control using the following code samples. To know more about import and export, refer to this documentation.
[VBHTML]
@Imports Syncfusion.EJ2 <div id="ControlRegion"> @Html.EJS().Spreadsheet("spreadsheet").OpenUrl("Home/Open").SaveUrl("Home/Save").Render() </div>
[CONTROLLER]
Option Strict On Imports Syncfusion.EJ2.Spreadsheet Public Class HomeController Inherits System.Web.Mvc.Controller Function Index() As ActionResult Return View() End Function Function About() As ActionResult Return View() End Function Function Contact() As ActionResult ViewData("Message") = "Your contact page." Return View() End Function // Importing the file into the spreadsheet component. Function Open(OpenRequest As OpenRequest) As ActionResult Return Content(Workbook.Open(OpenRequest)) End Function // Exporting the file. Function Save(saveSettings As SaveSettings) As ActionResult Workbook.Save(saveSettings) End Function End Class
Sample:
https://www.syncfusion.com/downloads/support/directtrac/general/ze/VB_Sample1791987535.zip
Conclusion
I hope you enjoyed learning about how to render the ASP.NET MVC Spreadsheet control in the ASP.NET MVC Visual Basic.
You can refer to our ASP.NET MVC Spreadsheet’s feature tour page to know about its other groundbreaking feature representations. You can also explore our ASP.NET MVC Spreadsheet examples to understand how to present and manipulate data.
For current customers, you can check out our ASP.NET MVC components from the License and Downloads page. If you are new to Syncfusion, you can try our 30-day free trial to check out our ASP.NET MVC Spreadsheet and other ASP.NET MVC components.
If you have any queries or require clarifications, please let us know in comments below. You can also contact us through our support forums, Direct-Trac, or feedback portal. We are always happy to assist you!