The FlexSheet control in your application can be unbound, bound to a data source, and can even display data loaded from an excel file. It offers you a flexible spreadsheet experience, allowing you to load existing excel file or workbook in FlexSheet, modify its data and even save it as an excel or a workbook file remotely or on the client side.
The quick start guides you through the steps of using the FlexSheet control in your application, and load an excel file or workbook instance in it on the server side. This can be accomplished in the following steps:
The following image shows workbook data loaded from the server in the FlexSheet control.
Create an ASP.NET Core MVC Application (.NET Framework) using Visual Studio templates. For more information, see Configuring MVC application using Visual Studio template.
Note: "C1.AspNetCore.Mvc"
gets added under the "dependencies" within project.json file of your project once you restore the packages.
Complete the following steps to configure your application to use Financial Charts.
_ViewImports |
Copy Code
|
---|---|
@addTagHelper *, C1.AspNetCore.Mvc @addTagHelper *, C1.AspNetCore.Mvc.FlexSheet |
Complete the following steps to register the required resources for using FlexSheet control.
_Layout.cshtml
to open it.<head></head>
tags.
_Layout.cshtml |
Copy Code
|
---|---|
<c1-styles /> <c1-scripts> <c1-flex-sheet-scripts /> </c1-scripts> |
For more information on how to register resources, refer to Registering Resources.
Loading Excel files in FlexSheet and saving FlexSheet data to Excel files have dependency on jszip.min.js file. Therefore, you need to add it in your application, and provide reference to it in the respective view or in <head> section of _Layout.cshtml file. Complete the following steps to add the jszip.min.js file to your application.
Complete the following steps to initialize a FlexSheet control.
Add a new Controller
Default1Controller
).C# |
Copy Code
|
---|---|
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; |
C# |
Copy Code
|
---|---|
// GET: ServerLoad public ActionResult Index() { return View(); } |
Add a View for the controller:
Index()
.Index.cshtml
to open it.HTML |
Copy Code
|
---|---|
<script src= "http://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"> </script> <div> <c1-flex-sheet class="flexSheet" file-path="~/FilestoLoad /Workbook.xlsx" height="800px" width="1500px"></c1-flex-sheet> </div> |