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

## Environment

<table>
 <tr>
  <td>Product</td>
  <td>SpreadSheet for Progress® Telerik® UI for ASP.NET MVC</td>
 </tr>
</table>

## Description

I have implemented a [Spreadsheet Server Export](https://demos.telerik.com/aspnet-core/spreadsheet/server-side-import-export) however I need to convert the exported Workbook to be usable with your [Document Processing Library](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/working-with-workbooks/working-with-workbooks-what-is-workbook) so I can modify it further. How can I achieve this?

## Differences

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.

* [MVC Worksheet server-side API](https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/server-side-programming/overview#telerikwebspreadsheetworksheet-properties-and-methods)
* [MVC Row server-side API](https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/server-side-programming/overview#telerikwebspreadsheetrow-properties-and-methods)
* [MVC Cell server-side API](https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/server-side-programming/overview#telerikwebspreadsheetcell-properties)
* [DPL Worksheet Documentation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/working-with-worksheets/what-is-worksheet)
* [DPL Cells Documentation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/working-with-cells/what-is-cell)
* [DPL Rows and Columns Documentation](https://docs.telerik.com/devtools/document-processing/libraries/radspreadprocessing/working-with-rows-and-columns/what-is-row-column)
* [DPL Workbook API](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Spreadsheet.Model.Workbook.html)
* [DPL Worksheet API](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Spreadsheet.Model.Worksheet.html)
* [DPL Sheet API](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Spreadsheet.Model.Sheet.html)
* [DPL Cells API](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Spreadsheet.Model.Cells.html)
* [DPL CellSelection API](https://docs.telerik.com/devtools/document-processing/api/Telerik.Windows.Documents.Spreadsheet.Model.CellSelection.html)

## 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;

```C#
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" });
MVCWorksheet.AddRow(row);
 
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)
    .Value.ToString();
```

## More ASP.NET MVC Spreadsheet Resources

* [ASP.NET MVC Spreadsheet Documentation](https://www.telerik.com/aspnet-mvc/documentation/html-helpers/data-management/spreadsheet/overview)

* [ASP.NET MVC Spreadsheet Demos](https://demos.telerik.com/aspnet-mvc/spreadsheet/index)

* [ASP.NET MVC Spreadsheet Product Page](https://www.telerik.com/aspnet-mvc/spreadsheet)

* [Telerik UI for ASP.NET MVC Video Onboarding Course (Free for trial users and license holders)](https://www.telerik.com/aspnet-mvc/documentation/getting-started/video-onboarding)

* [Telerik UI for ASP.NET MVC Forums](https://www.telerik.com/forums/aspnet-mvc)

## See Also

* [Client-Side API Reference of the Spreadsheet for ASP.NET MVC](https://docs.telerik.com/kendo-ui/api/ui/spreadsheet)
* [Server-Side API Reference of the Spreadsheet for ASP.NET MVC](https://docs.telerik.com/aspnet-mvc/api/spreadsheet)
* [Telerik UI for ASP.NET MVC Breaking Changes](https://www.telerik.com/aspnet-mvc/documentation/backwards-compatibility/2023-backwards-compatibility)
* [Telerik UI for ASP.NET MVC Knowledge Base](https://docs.telerik.com/aspnet-mvc/knowledge-base)
