We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date

Save to Server

Is there a way to save the data in a spreadsheet control to the server? I don't mind downloading it to client, but I would like to keep changes on the server side too.

Spreadsheet.Save(sheetModel, sheetData, filename, ExportFormat.XLSX, ExcelVersion.Excel2013);

1 Reply

SI Silambarasan I Syncfusion Team November 8, 2016 12:39 PM UTC

Hi Will, 
Thank you for using Syncfusion products. 
Your requirement “To save the data in a Spreadsheet control to the server” can be achieved by using ‘Save()’ method in Spreadsheet.  Please refer the following code example. 
public void ExportToExcel(string sheetModel, string sheetData, string password) 
    SaveFileToDB(sheetModel, sheetData); 
public void SaveFileToDB(string sheetModel, string sheetData) 
    string dbConnectionStr = @"Data Source=(LocalDB)\v11.0;AttachDbFilename=|DataDirectory|\spreadsheetDB.mdf;Integrated Security=True"; 
    SqlConnection sqlCon = new SqlConnection(dbConnectionStr); 
    //Get Spreadsheet data as Stream 
    Stream streamData = Spreadsheet.Save(sheetModel, sheetData, ExportFormat.XLSX, ExcelVersion.Excel2013); 
    Byte[] dataBytes = ((MemoryStream)streamData).ToArray(); 
    SqlCommand sqlComm = new SqlCommand("INSERT INTO [dbo].[Table]([FileName], [FileData]) VALUES (@FileName, @FileData)", sqlCon); 
    sqlComm.Parameters.AddWithValue("@FileName", "Sample"); 
    sqlComm.Parameters.AddWithValue("@FileData", dataBytes); 
        excelUrl: "/Home/ExportToExcel", 
For your convenience, we have prepared a sample to demonstrate this and the same can be downloaded from the below link, 
Silambarasan I 

Live Chat Icon For mobile
Up arrow icon