# 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 Core</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 **Core**) suite and Document Processing Library(later referred as **DPL**) both have Workbook and Worksheet classes which have different capabilities.

* [Core Worksheet server-side API](https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/server-side-programming/overview#telerikwebspreadsheetworksheet-properties-and-methods)
* [Core Row server-side API](https://docs.telerik.com/devtools/aspnet-ajax/controls/spreadsheet/server-side-programming/overview#telerikwebspreadsheetrow-properties-and-methods)
* [Core 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 Core and DPL are not interchangeable. Nevertheless, the Core Workbook class has some methods that allow converting from one to another and vice-versa:

* An instance method .ToDocument() that all allows any Core Workbook instance to be converted to a DPL Workbook;
* A static method Workbook.FromDocument() that allows any DPL Workbook to be converted to a Core Workbook;

```C#
using System;
using DPL = Telerik.Windows.Documents.Spreadsheet.Model;
using Core = Telerik.Web.Spreadsheet;
using System.Collections.Generic;

// Core to Document Processing Library
Core.Workbook CoreWorkbook = new Core.Workbook();
Core.Worksheet CoreWorksheet = CoreWorkbook.AddSheet();
 
Core.Row row = new Core.Row() { Index = 2, Cells = new List<Core.Cell> { } };
row.AddCell(new Core.Cell() { Index = 2, Value = "Test cell" });
CoreWorksheet.AddRow(row);
 
DPL.Workbook dplWorkbook = CoreWorkbook.ToDocument();
DPL.Sheet dplSheet = dplWorkbook.Sheets[0];
DPL.Worksheet dplWorksheet =  dplWorkbook.Worksheets[0];
 
// Document Processing Library to Core
Core.Workbook convertedCoreWorkbook = Core.Workbook.FromDocument(dplWorkbook);
Core.Worksheet convertedCoreWorksheet = convertedCoreWorkbook.Sheets[0];
 
// value is "Test cell"
string value = convertedCoreWorksheet
    .Rows.Find(r=> r.Index == 2)
    .Cells.Find(c=> c.Index == 2)
    .Value.ToString();
```

## More ASP.NET Core Spreadsheet Resources

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

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

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

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

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

## See Also

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