New to Telerik UI for ASP.NET MVC? Download free 30-day trial

Understanding Telerik.Web.Spreadsheet and Document Processing Library Spreadsheet Workbook and Worksheets


I have implemented a Spreadsheet Server Export however I need to convert the exported Workbook to be usable with your Document Processing Library so I can modify it further. How can I achieve this?


The assemblies from the Telerik.Web.Spreadsheet(later referred as MVC) suite and Document Processing Library(later referred as DPL) both have Workbook and Worksheet classes which have different capabilities.

Converting from One to the Other

The Workbook and worksheets from the MVC and DPL are not interchangeable. Nevertheless, the MVC Workbook class has some methods that allow converting from one to another and vice-versa:

  • An instance method .ToDocument() that all allows any MVC Workbook instance to be converted to a DPL Workbook;
  • A static method Workbook.FromDocument() that allows any DPL Workbook to be converted to an MVC Workbook;
using System;
using DPL = Telerik.Windows.Documents.Spreadsheet.Model;
using MVC = Telerik.Web.Spreadsheet;
using System.Collections.Generic;
// MVC to Document Processing Library
MVC.Workbook MVCWorkbook = new MVC.Workbook();
MVC.Worksheet MVCWorksheet = MVCWorkbook.AddSheet();

MVC.Row row = new MVC.Row() { Index = 2, Cells = new List<MVC.Cell> { } };
row.AddCell(new MVC.Cell() { Index = 2, Value = "Test cell" });

DPL.Workbook dplWorkbook = MVCWorkbook.ToDocument();
DPL.Sheet dplSheet = dplWorkbook.Sheets[0];
DPL.Worksheet dplWorksheet =  dplWorkbook.Worksheets[0];

// Document Processing Library to MVC
MVC.Workbook convertedMVCWorkbook = MVC.Workbook.FromDocument(dplWorkbook);
MVC.Worksheet convertedMVCWorksheet = convertedMVCWorkbook.Sheets[0];

// value is "Test cell"
string value = convertedMVCWorksheet
    .Rows.Find(r=> r.Index == 2)
    .Cells.Find(c=> c.Index == 2)

More ASP.NET MVC Spreadsheet Resources

See Also

In this article