Completed
Last Updated: 14 Jun 2019 12:34 by ADMIN
Marco Piumi
Created on: 06 Nov 2015 20:42
Category: Spreadsheet
Type: Feature Request
1
Open, Edit and Save in RadSpreadsheet Control.
Can this control open, edit and save Excel File from Code.
Open a File from code and not in Page_Init event.
2 comments
ADMIN
Peter Milchev
Posted on: 14 Jun 2019 12:34
Hello guys,

There is a SpreadsheetDocumentProvider provider that can be used to load and save Excel files: https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/providers/using-a-data-provider

If any data manipulation is needed before/after loading/saving, the following KB articles can be followed: 

 

If the Spreadsheet needs to be populated programmatically, there are two options: 

1) Using CustomProvider: https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/data-binding/providers/custom-database-provider;

2) Adding Sheets, rows and cells programmatically and then adding them to the Spreadsheet: 

using System;
 
using AJAX = Telerik.Web.Spreadsheet;
using System.Collections.Generic;
 
public partial class Default : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        AJAX.Workbook ajaxWorkbook = new AJAX.Workbook();
        AJAX.Worksheet ajaxWorksheet = ajaxWorkbook.AddSheet();
 
        AJAX.Row row = new AJAX.Row() { Index = 2, Cells = new List<AJAX.Cell> { } };
        row.AddCell(new AJAX.Cell() { Index = 2, Value = "Test cell" });
        ajaxWorksheet.AddRow(row);
 
        RadSpreadsheet1.Sheets.Add(ajaxWorksheet);
    }
}

If an Excel file needs to be loaded manually, the DocumentProcessingLibrary can be used and then the DPL workbook can be converted to AJAX workbook and adding the sheets from the workbook to the RadSpreadsheet will do the job.

Regards,
Peter Milchev
Progress Telerik
Get quickly onboarded and successful with your Telerik and/or Kendo UI products with the Virtual Classroom free technical training, available to all active customers. Learn More.
Peter Marchal
Posted on: 08 Jun 2019 14:10
How to save changes to the file?