Articles in this section
Category / Section

How to render the ASP.NET MVC Spreadsheet control in the ASP.NET MVC Visual Basic?

3 mins read

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

 

 

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.

 

Create a new project in ASP.NET MVC Spreadsheet

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.

 

Configure your new project in ASP.NET MVC Spreadsheet

 

Step 5: After clicking Create, it will show another popup to select the web application template. Select the MVC template.

 

Create a new ASP.NET web application in ASP.NET MVC Spreadsheet

 

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.

 

Manage NuGet packages in ASP.NET MVC Spreadsheet

 

Step 2: Search Syncfusion.EJ2.MVC5 NuGet package in the browse tab. Find the respective NuGet, select it, and install it.

 

Installing Syncfusion.EJ2.MVC5 package in ASP.NET MVC Spreadsheet  

Step 3: Search Syncfusion.EJ2.Spreadsheet.AspNet.MVC5 NuGet package in the browse tab. Find the respective NuGet, select it, and install it.

 

Installing Syncfusion.EJ2.Spreadsheet.AspNet.MVC5 package in ASP.NET MVC Spreadsheet

 

Step 4: After successfully installing NuGet packages, it will automatically add the required assembly reference in the Web.config file.

 

Web Config snippet

 

Step 5: Add the Stylesheet and Script reference in the <head> of ~/Views/Shared/_Layout.vbhtml.  

 

Adding Stylesheet and Script reference

 

Step 6: Register the Syncfusion Script Manager EJS().ScriptManager() at the end of the <body> of the ~/Views/Shared/_Layout.vbhtml.

 

Adding Script Manager in ASP.NET MVC Spreadsheet

 

Step 7: Now, add the ASP.Net MVC Spreadsheet control in the ~/Views/Home/Index.vbhtml.

 

Control render in ASP.NET MVC Spreadsheet

 

Step 8: Press F5 to run the application. Find the output as follows.

Output:

 

Output in ASP.NET MVC Spreadsheet

 

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 forumsDirect-Trac, or feedback portal. We are always happy to assist you!

 

Did you find this information helpful?
Yes
No
Help us improve this page
Please provide feedback or comments
Comments (0)
Please  to leave a comment
Access denied
Access denied