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.
Complete the following steps to license your application for using FlexSheet control.
licenses.licx |
Copy Code
|
---|---|
C1.Web.Mvc.LicenseDetector, C1.Web.Mvc C1.Web.Mvc.Sheet.LicenseDetector, C1.Web.Mvc.FlexSheet |
For more information on how to add license to your application, refer to Licensing.
Complete the following steps to add the ASP.NET MVC Edition references and FlexSheet references to your project.
Complete the following steps to configure your application to use Financial Charts.
web.config
file to open it.<system.web.webPages.razor></system.web.webPages.razor>
tags.
HTML |
Copy Code
|
---|---|
<add namespace="C1.Web.Mvc" /> <add namespace="C1.Web.Mvc.Fluent" /> <add namespace="C1.Web.Mvc.Sheet" /> <add namespace="C1.Web.Mvc.Sheet.Fluent" /> |
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
|
---|---|
@Html.C1().Styles() @Html.C1().Scripts().Basic().FlexSheet() |
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; |
Add a View for the controller:
Index()
.Index.cshtml
to open it.Index.cshtml |
Copy Code
|
---|---|
<script src="http://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> <div> @(Html.C1().FlexSheet().Load("~/Content/ExcelFiles/WorkBook.xlsx").Width(1500).Height(800) ) </div> |
Index.vbhtml |
Copy Code
|
---|---|
@Imports C1.Web.Mvc @Imports C1.Web.Mvc.FlexSheet.Fluent @Imports C1.Web.Mvc.FlexSheet @Imports C1.Web.Mvc.Grid <script src="http://cdnjs.cloudflare.com/ajax/libs/jszip/2.5.0/jszip.min.js"></script> @(Html.C1().FlexSheet() _ .Load("~/Content/ExcelFiles/Product.xlsx") _ .Width("1500px") _ .Height("800px") ) |