How do i Customize Open,Export and Save of Spreadsheet

i want use Spreadsheet control into my MVC application. if i use Controller then  in this method
[AcceptVerbs(HttpVerbs.Post)]
        public ActionResult Import(ImportRequest importRequest)
        {
            importRequest.Url = "http://mvc.syncfusion.com/Spreadsheet/LargeData.xlsx";
            return importRequest.SpreadsheetActions();
        }
i cannot find SpreadsheetActions() in importRequest.
and kindly guide me how do i use Spreadsheet with my api not the default api calls.

22 Replies

SI Silambarasan I Syncfusion Team October 4, 2018 09:21 AM UTC

Hi ASIM TAUSIF KHAN, 
 
Thank you for contacting Syncfusion support. 
 
Query #1 “I cannot find SpreadsheetActions() in importRequest” 
 
We have checked this query by preparing sample with the reported scenario and the Spreadsheet importing working fine in our end. We suspect that the namespace references are not referred properly in your project. Please ensure highlighted references from the following code example. 
 
CONTROLLER 
 
using Syncfusion.JavaScript.Models; 
using Syncfusion.JavaScript; 
using Syncfusion.EJ.Export; 
using Syncfusion.XlsIO; 
 
//... 
 
[AcceptVerbs(HttpVerbs.Post)] 
public ActionResult Import(ImportRequest importRequest) 
      importRequest.Url = "http://mvc.syncfusion.com/Spreadsheet/LargeData.xlsx"; 
      return importRequest.SpreadsheetActions(); 
 
 
 
Query #2 “how do I use Spreadsheet with my api not the default api calls?” 
 
We have checked this query and we suspect that you want to import excel files based on your controller actions other than default action call i.e. using ‘importMapper’.  Already, we have demonstrated those similar requirements in the below KB documentation links. 
 
 
Could you please check the above KB documentations and get back to us with more information whether your requirement is not fulfilled or if we misunderstood? 
 
Regards, 
Silambarasan 



AT ASIM TAUSIF KHAN October 4, 2018 11:02 AM UTC

Thanks for your  reply Salim.one more question how can i load some excel file from my system in MVC application.with ajax by passing filename.


SI Silambarasan I Syncfusion Team October 5, 2018 10:59 AM UTC

Hi ASIM TAUSIF KHAN, 
 
Thanks for your update. 
 
We have prepared a sample to demonstrate your requirement “To load excel file in Spreadsheet by passing filename using AJAX” and the same can be downloaded from the below sample link. 
 
 
CODE EXAMPLE: 

CSHTML 
<input type="text" id="fileName" /> 
<input type="button" value="Load Excel" onclick="loadExcel()" /> 
@(Html.EJ().Spreadsheet<object>("Spreadsheet") 
    //.. 
) 
 
// Load excel file from the server to the Spreadsheet. 
function loadExcel(args) { 
    var xlObj = $("#Spreadsheet").data("ejSpreadsheet"), fileName = $("#fileName").val(); 
    $.ajax({ 
        type: "POST", 
        url: "/Spreadsheet/loadExcel", 
        data: { fileName: fileName }, 
        success: function (data) { 
            xlObj.loadFromJSON(JSON.parse(data)); 
        } 
    }); 
 
CS 
//Open saved Excel file from server. 
[AcceptVerbs(HttpVerbs.Post)] 
public string loadExcel(string fileName) 
{ 
    string path = Server.MapPath("~/Files/" + fileName) , jsonData; 
    try 
    { 
        Stream fileStream = System.IO.File.Open(path, FileMode.Open, FileAccess.Read); 
        ImportRequest impReq = new ImportRequest(); 
        impReq.FileStream = fileStream; 
        jsonData = Spreadsheet.Open(impReq); 
        fileStream.Close(); 
        return jsonData; 
    } 
    catch (Exception ex) 
    { 
        return "Failure"; 
    } 
} 
 
Please refer the below KB link for more information. 
 
Could you please check the above sample and get back to us with more information if you need any further assistance on this? 
 
Regards, 
Silambarasan 



AT ASIM TAUSIF KHAN October 16, 2018 11:34 AM UTC

Thanks for you reply.also guide me how to save to server with ajax call.i tried your following link

but controller method is not hitting in MVC.kindly send me a sample project


SI Silambarasan I Syncfusion Team October 18, 2018 06:17 AM UTC

Hi ASIM TAUSIF KHAN,  
  
Thanks for your update.  
  
We have prepared a sample to demonstrate your requirement “To save excel file in Server using AJAX” and the same can be downloaded from the below sample link. In that, we have checked that the controller method is invoked properly and working fine in our end. 
  
Sample: 
  
Code Example:  
CSHTML 
 
<input type="text" id="fileName" /> 
<input type="button" value="Save as Excel" onclick="saveAsExcel()" /> 
 
@(Html.EJ().Spreadsheet<object>("Spreadsheet") 
    //.. 
) 
 
// Save excel file to the server. 
function saveAsExcel(args) { 
    var xlObj = $("#Spreadsheet").data("ejSpreadsheet"), fileName = $("#fileName").val(), exportProp = xlObj.XLExport.getExportProps(); 
    $.ajax({ 
        type: "POST", 
        url: "/Spreadsheet/saveAsExcel", 
        data: { fileName: fileName, sheetModel: exportProp.model, sheetData: exportProp.data }, 
        success: function () { 
            alert("File saved successfully"); 
        } 
    }); 
} 
 
 
 
CS 
 
// Save the Spreadsheet data as Excel to server. 
[AcceptVerbs(HttpVerbs.Post)] 
public string saveAsExcel(string fileName, string sheetModel, string sheetData) 
{ 
    //File Save to server here 
    ExcelEngine excelEngine = new ExcelEngine(); 
    IApplication application = excelEngine.Excel; 
    try 
    { 
        // Convert Spreadsheet data as Stream 
        var fileStream = Spreadsheet.Save(sheetModel, sheetData, ExportFormat.XLSX, ExcelVersion.Excel2013); 
        fileStream.Position = 0; //Reset reader position 
        IWorkbook workbook = application.Workbooks.Open(fileStream); 
        var filePath = Server.MapPath("~/Files/" + fileName); 
        workbook.SaveAs(filePath); 
        return "Success"; 
    } 
    catch (Exception ex) 
    { 
        return "Failure"; 
    } 
} 
 
 
 
Could you please check the above sample and get back to us with more information if you need any further assistance on this?  
  
Regards, 
Silambarasan 



AT ASIM TAUSIF KHAN October 23, 2018 12:05 PM UTC

Thnx for your answer.in spread sheet ther is no Open button in File Menu.Kindly guide me how to show it.when i deploy it on IIS file loading is very very slow.tell me any solution


CI Christopher Issac Sunder K Syncfusion Team October 25, 2018 07:15 AM UTC

Hi ASIM, 

Thank you for your update. 

#1: In spreadSheet there is no Open button in File Menu. Kindly guide me how to show it. 
 
We have checked your query and to enable open option in Spreadsheet set AllowImport option to true and also set ImportMapper in ImportSettings to map server action. 


Please check the above documentation to enable the Open option in Spreadsheet and get back to us if you need any further assistance on this? 

#2: when i deploy it on IIS file loading is very very slow.tell me any solution? 

We would like to let you know that the ej.web.all.min.js file contains script for all major components like Spreadsheet, Grid, Chart and TreeGrid etc. The time delay for loading ej.web.all.min.js file will depend upon the network. Could you please let us know that you are using all the Syncfusion components or you want to use only specific components? if you want to generate the script file for specific components you can make use of Custom Script Generator (CSG) tool.    
  

Could you please check the above link or get back to us with more information if you need any further assistance on this?   

Thanks, 
Christo


AT ASIM TAUSIF KHAN October 25, 2018 02:06 PM UTC

when i tried to login https://csg.syncfusion.com/  i got following error

Sorry, an error occurred while processing your request.




AT ASIM TAUSIF KHAN October 28, 2018 10:28 AM UTC

Hi.i am using only spreadsheet and diagram.can you please provide me js only for these tools.


SI Silambarasan I Syncfusion Team October 29, 2018 06:28 AM UTC

Hi ASIM, 
 
Thanks for your update. 
 
We can reproduce the Custom Script Generator (CSG) login issue in some of the machine browser and now, we have resolved & refreshed it in online. Please check again the below link to generate the script with your current product version.  
 
If still you are facing the issue, please share the below details.  
S.no 
Item details 
Comments 
List of controls 
Please add control names if other than below controls that you want. 
1.       Spreadsheet 
2.       Diagram 
Theme name 
 
Version    
 
1. 
2. 
3. 
4. 
Custom options like 
Individual 
MapFile   
Minified   
Non-Minified 
 
  
Regards, 
Silambarasan Ilango 



AT ASIM TAUSIF KHAN October 30, 2018 07:51 AM UTC

Hi i need Diagram, Spreadsheet ,PDF Viewer , Signature , Dialog ,PowerPoint ,

version = 16.3460.0.21 

Individual


SI Silambarasan I Syncfusion Team October 31, 2018 12:19 PM UTC

Hi ASIM, 
 
Thanks for your update. 
 
As based on your request, we have generated the individual script files for the components (Diagram, Spreadsheet, PDF Viewer, Signature, Dialog) from CSG in version 16.3.0.21 and the same can be downloaded from the below link. 
 
Also, you have mentioned ‘PowerPoint’ in the component list that want to generate custom script and it’s not applicable one since it’s a file formats (.Net class library). 
 
Could you please check the above attached individual script files and get back to us if you faced any issues or need further assistance? 
 
Regards, 
Silambarasan 



AT ASIM TAUSIF KHAN November 1, 2018 06:30 AM UTC

i am getting error.could you please use this custom script in a MVC project and share that project with me.in which all mentioned control are working.


SI Silambarasan I Syncfusion Team November 2, 2018 01:03 AM UTC

Hi ASIM, 
 
Thank you for your update. 
 
As per your request, we have prepared a MVC sample using the provided individual scripts and you can find the sample from the below link, 
 
 
Could you please check the sample and get back to us with more information if you need any further assistance on this? 
 
Regards, 
Silambarasan 



AT ASIM TAUSIF KHAN November 3, 2018 08:05 AM UTC

could you please add DiagramBuilder also in the project.


CI Christopher Issac Sunder K Syncfusion Team November 5, 2018 10:26 AM UTC

Hi ASIM,  

Thanks for the update. We have created a standalone diagram builder sample in MVC and you can integrate it with your project.  


Please let me know if any concerns.  

Thanks, 
Christo


AT ASIM TAUSIF KHAN November 18, 2018 12:41 PM UTC

could you please add DiagramBuilder in a standalone mvc web with version = 16.3460.0.21 


RT Ramya Thirugnanam Syncfusion Team November 21, 2018 04:26 AM UTC

Hi ASIM,   
 
Please find the stand-alone diagram builder (4.6v) as below. 
 
 
Regards, 
Ramya T 



AT ASIM TAUSIF KHAN December 19, 2018 06:59 AM UTC

Hi,
     whenever i open some excel file from system some file open and some file give System.OutOfMemoryExceptions and also took so much time.could you please tell me the reason or solve this issue.


SI Silambarasan I Syncfusion Team December 19, 2018 12:56 PM UTC

Hi ASIM, 
 
We have checked the reported issue (getting System.OutOfMemoryExceptions) in the version (16.3.0.21) by importing excel files randomly (that includes all default functionalities) and these excel files are imported properly in our end.  
 
Before we proceed further, we would like to know the following detail. 
 
1. Could you please share us the excel (or dummy excel) that you have loaded in the Spreadsheet which throws exception ‘System.OutOfMemoryExceptions’ or provide the Spreadsheet loaded data as JSON to replicate this issue in our end? So, that we can analyze based on your scenario and provide you a better solution.  
 
The information provided would be great help for us to resolve your issue. 
 
Regards, 
Silambarasan 



AT ASIM TAUSIF KHAN December 19, 2018 01:08 PM UTC

Hi,
    Actually this is happening when i publish my project on IIS and most of the time got memory exception.kindly check attached file .

Attachment: FQC02_VM_record_(rev.02)_1b64f0c4.7z


MV Madhan Venkateshan Syncfusion Team December 20, 2018 05:57 PM UTC

Hi ASIM, 
 
Thank you for your update. 
 
We have checked the excel file (F-QC-02 %VM record (rev.02).xlsx) that you have provided, and it has four sheets (MFR, %VM, %ASH, Pellet appearance). In each sheet has cell formats (like font-family, text-indent, text-align) are applied in 126 rows and 16138 columns, but sheet data is filled up to range “A1:O42”. Could you please provide more details about your exact requirement for applying cell formats in empty cells? 
 
Meanwhile, we have modified the provided excel file by removing the cell formatting applied in the empty cells. We would like to suggest you apply the cell formatting to all the cells after importing the excel file in Spreadsheet. 
 
 
Could you please check the above excel file and get back to us with the requested information, so we can analyze based on that and provide you a better solution?  The information provided would be great help for us to proceed further. 
 
Regards, 
Vinoth Kumar S 


Loader.
Up arrow icon