Skip to content

Commit 8a4b120

Browse files
Added info for importing with SpreadStreamProcessing
1 parent 6329711 commit 8a4b120

File tree

8 files changed

+225
-41
lines changed

8 files changed

+225
-41
lines changed

introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ Telerik Document Processing features the following components:
5050

5151
* [RadSpreadProcessing]({%slug radspreadprocessing-overview%}): A library that allows you to create, import and export XLSX (Excel Workbook), XLS (Excel 97-2003 Workbook), CSV and TXT spreadsheet documents. It also allows you to export all these formats to PDF.
5252

53-
* [RadSpreadStreamProcessing]({%slug radspreadstreamprocessing-overview%}): A library that allows you to export large XLSX and CSV spreadsheet documents with low memory footprint and great performance.
53+
* [RadSpreadStreamProcessing]({%slug radspreadstreamprocessing-overview%}): A library that allows you to export and read large XLSX and CSV spreadsheet documents with low memory footprint and great performance.
5454

5555
* [RadWordsProcessing]({%slug radwordsprocessing-overview%}): A library that allows you to create, import and export DOCX (Word Document), DOC & DOT (import only), HTML, RTF and TXT documents. It also allows you to export all these formats to PDF.
5656

libraries/radspreadstreamprocessing/getting-started.md

Lines changed: 43 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ In order to use **RadSpreadStreamProcessing** in your project, you will need to
5858
</tbody>
5959
</table>
6060

61-
>note The binaries compatible with .NET Standard are distributed with the packages targeting .NET Standard and .NET Core. You can obtain the assemblies through the **UI for ASP.NET Core**, **UI for Blazor** and **UI for Xamarin** suites. There are **NuGet** packages as well that you can access if you have a license for one of the above mentioned suites.
61+
>note The binaries compatible with .NET Standard are distributed with the packages targeting .NET Standard and .NET Core. For the full list of suites including Telerik Document Processing, check the [Installing on Your Computer]({%slug installation-installing-on-your-computer%}) help topic. There are **NuGet** packages as well that you can access if you have a license for one of the above mentioned suites.
6262
6363
## Create a Spreadsheet Document
6464

@@ -143,6 +143,48 @@ When creating a document with **RadSpreadStreаmProcessing**, you should have in
143143
![](images/SpreadStreamProcessing-GettingStarted_01.png)
144144

145145

146+
## Read Existing Document
147+
148+
When reading a document with **RadSpreadStreаmProcessing**, you should have in mind that the order of parsing the content is much important. To achieve the low resources usage, the library parses only the required by the user data and, due to the format restrictions of the way the content is presented in the structure of the file, you have to create the desired elements in a sequence keeping the following consecution:
149+
150+
151+
1. Read the Workbook
152+
153+
2. Read a Worksheet
154+
155+
3. Read Columns (optional)
156+
157+
4. Read Rows (a worksheet must contain at least one row)
158+
159+
5. Read Cells (optional)
160+
161+
**Example 2** demonstrates how you could read the data from an existing document.
162+
163+
#### [C#] **Example 2: Read data from a document**
164+
165+
{{region radspreadstreamprocessing-getting-started_1}}
166+
167+
using (FileStream fs = new FileStream(fileName, FileMode.Open))
168+
{
169+
using (IWorkbookImporter workBookImporter = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, fs))
170+
{
171+
foreach (IWorksheetImporter worksheetImporter in workBookImporter.WorksheetImporters)
172+
{
173+
foreach (IRowImporter rowImporter in worksheetImporter.Rows)
174+
{
175+
foreach (ICellImporter cell in rowImporter.Cells)
176+
{
177+
string value = cell.Value;
178+
}
179+
}
180+
}
181+
}
182+
}
183+
184+
{{endregion}}
185+
186+
187+
146188
## See Also
147189

148190
* [Using Telerik Document Processing First Steps]({%slug getting-started-first-steps%})
Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
title: Import
3+
page_title: Import
4+
slug: radspreadstreamprocessing-import
5+
tags: import, read, parse, xlsx, csv
6+
published: True
7+
position: 4
8+
---
9+
10+
# Import
11+
12+
With **RadSpreadStreamProcessing** you can read spreadsheet documents from the following file formats:
13+
14+
* XLSX
15+
16+
* CSV
17+
18+
This functionality is introduced in R3 2022.
19+
20+
## Specifics
21+
22+
The library reads dynamically the document content. To achieve this, each of the classes responsible for importing the elements of the document implement **IDisposable** and keeps the corresponding content and settings into the memory until it is disposed.
23+
24+
## Read File Data
25+
26+
To read the data from a file, you should parse the desired elements in a sequence keeping the following consecution:
27+
28+
1. Read the Workbook
29+
30+
2. Read a Worksheet
31+
32+
3. Read Columns (optional)
33+
34+
4. Read Rows
35+
36+
5. Read Cells
37+
38+
39+
#### [C#] **Example 1: Read data from a document**
40+
41+
{{region radspreadstreamprocessing-import_0}}
42+
43+
using (FileStream fs = new FileStream(fileName, FileMode.Open))
44+
{
45+
using (IWorkbookImporter workBookImporter = SpreadImporter.CreateWorkbookImporter(SpreadDocumentFormat.Xlsx, fs))
46+
{
47+
foreach (IWorksheetImporter worksheetImporter in workBookImporter.WorksheetImporters)
48+
{
49+
foreach (IRowImporter rowImporter in worksheetImporter.Rows)
50+
{
51+
foreach (ICellImporter cell in rowImporter.Cells)
52+
{
53+
string value = cell.Value;
54+
}
55+
}
56+
}
57+
}
58+
}
59+
60+
{{endregion}}
61+
62+
Through the importer objects, you can access the properties of the different elements.
63+
64+
## See Also
65+
66+
* [Getting Started]({%slug radspreadstreamprocessing-getting-started%})
67+
* [Workbook]({%slug radspreadstreamprocessing-model-workbook%})

libraries/radspreadstreamprocessing/model/cells.md

Lines changed: 34 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ position: 5
1111

1212
This article will help you get familiar with the concept of a cell and its features.
1313

14-
* [What is a Cell](#what-is-a-cell)
15-
16-
* [ICellExporter Interface](#icellexporter-interface)
17-
18-
* [Using ICellExporter](#using-icolumnexporter)
19-
2014

2115
## What is a Cell
2216

2317
A cell is the basic data unit in a worksheet. Cells are organized in rows and columns and can also be referred as an intersection point of a column and a row. Cells are identified by a letter and number combination that indicates the letter of their column and the number of their row. For example, the top left cell is referred to as A1 and the bottom right cell is – XFD1048576.
2418

25-
## ICellExporter Interface
19+
## ICellExporter and ICellImporter Interface
2620

2721
In **RadSpreadStreamProcessing**, a cell could be exported through the [**ICellExporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.ICellExporter.html). It defines several methods allowing you to set different values and formats to a cell.
2822

23+
If you need to read the cell data and its properties, you should use the [**ICellImporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.ICellImporter.html).
24+
2925
## Using ICellExporter
3026

3127
A concrete instance of ICellExporter could be created through the **CreateCellExporter()** method of [IRowExporter]({%slug radspreadstreamprocessing-model-rows%}). **Example 1** demonstrates how you can add a cell to a row.
@@ -239,6 +235,37 @@ In addition to the listed properties, the SpreadCellFormat class allows you to s
239235

240236
A SpreadCellFormat instance could be applied on multiple cells. However, if a property of the format changes, the new settings will be applied to the cells formatted after the modification.
241237

238+
## Read a Cell
239+
240+
### Using ICellImporter
241+
242+
A concrete instance of ICellImporter could be obtained through the Cells collection of [IRowImporter]({%slug radspreadstreamprocessing-model-rows%}). **Example 8** demonstrates how you can read the cells of a row.
243+
244+
#### **[C#] Example 8: Create ICellImporter**
245+
246+
{{region cs-radspreadstreamprocessing-model-cells_7}}
247+
248+
foreach (ICellImporter cell in rowImporter.Cells)
249+
{
250+
string value = cell.Value;
251+
252+
SpreadCellFormat format = cell.Format;
253+
SpreadCellStyle style = cell.Format.CellStyle;
254+
}
255+
{{endregion}}
256+
257+
>ICellImporter inherits from [IDisposable](https://msdn.microsoft.com/en-us/library/system.idisposable(v=vs.110).aspx). Make sure the object is disposed when you are done with it. The best way to ensure this is handled properly is to wrap it in a *using* statement.
258+
259+
The ICellImporter interface exposes the following properties:
260+
261+
* **RowIndex**: Gets the index of the row the cell appears in.
262+
* **ColumnIndex**: Gets the index of the column the cell appears in.
263+
* **Format**: Gets the formatting applied to the cell. The property is of type [SpreadCellFormat](https://docs.telerik.com/devtools/document-processing/api/telerik.documents.spreadsheetstreaming.spreadcellformat).
264+
* **Value**: A string property that allows you get the value of the cell.
265+
* **ValueType**: Gets the value type of the cell. This property is enumeration of type [CellValueType](https://docs.telerik.com/devtools/document-processing/api/telerik.documents.spreadsheetstreaming.cellvaluetype)
266+
267+
268+
242269
## See Also
243270

244271
* [Rows]({%slug radspreadstreamprocessing-model-rows%})

libraries/radspreadstreamprocessing/model/column.md

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,16 @@ position: 3
1111

1212
This article will help you get familiar with the concept of a column and its features.
1313

14-
* [What is a Column](#what-is-a-column)
15-
16-
* [IColumnExporter Interface](#icolumnexporter-interface)
17-
18-
* [Using IColumnExporter](#using-icolumnexporter)
19-
20-
2114
## What is a Column
2215

2316
A column is a group of cells that are vertically stacked and appear on the same vertical line. Columns are identified by a letter or a combination of letters. For example, the first column is called A, the second one – B and the last column is XFD.
2417

25-
## IColumnExporter Interface
18+
## IColumnExporter and IColumnImporter Interfaces
2619

2720
In **RadSpreadStreamProcessing**, a column could be exported through the [**IColumnExporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.IColumnExporter.html). It defines several methods allowing you to change the appearance of a column.
2821

22+
To read a column and its properties, you should use the [**IColumnImporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.IColumnImporter.html).
23+
2924
### Using IColumnExporter
3025

3126
A concrete instance of IColumnExporter could be created through the CreateColumnExporter() method of [IWorksheetExporter]({%slug radspreadstreamprocessing-model-worksheet%}). **Example 1** demonstrates how you can add a column to a worksheet.
@@ -79,6 +74,32 @@ In some cases you may need to skip several columns and start filling the data in
7974
}
8075
{{endregion}}
8176

77+
## Read a Column
78+
79+
### Using IColumnImporter
80+
81+
A concrete instance of IColumnImporter could be obtained through the Columns collection of [IWorksheetImporter]({%slug radspreadstreamprocessing-model-worksheet%}). **Example 4** demonstrates how you can start reading a row from a worksheet.
82+
83+
#### **[C#] Example 4: Create IColumnImporter**
84+
85+
{{region cs-radspreadstreamprocessing-model-columns_3}}
86+
87+
foreach (IColumnImporter column in worksheetImporter.Columns)
88+
{
89+
}
90+
{{endregion}}
91+
92+
>IColumnImporter inherits from [IDisposable](https://msdn.microsoft.com/en-us/library/system.idisposable(v=vs.110).aspx). Make sure the object is disposed when you are done with it. The best way to ensure this is handled properly is to wrap it in a *using* statement.
93+
94+
The IColumnImporter interface exposes the following properties:
95+
96+
* **FromIndex**: Gets the first index of the column range with same properties.
97+
* **ToIndex**: Gets the last index of the column range with same properties.
98+
* **OutlineLevel**: Gets the outline level (used when grouping columns).
99+
* **IsCustomWidth**: Gets a value indicating whether the width applied to the current column is a custom one.
100+
* **WidthInPixels** and **WidthInCharacters**: Gets the width of the column in pixels and in characters, respectively.
101+
* **IsHidden**: Gets a value determining whether the row is hidden.
102+
82103
## See Also
83104

84105
* [Rows]({%slug radspreadstreamprocessing-model-rows%})

libraries/radspreadstreamprocessing/model/row.md

Lines changed: 31 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,21 +11,17 @@ position: 4
1111

1212
This article will help you get familiar with the concept of a row and its features.
1313

14-
* [What is a Row](#what-is-a-row)
15-
16-
* [IRowExporter Interface](#irowexporter-interface)
17-
18-
* [Using IRowExporter](#using-irowexporter)
19-
2014
## What is a Row
2115

2216
Rows in the terms of a spreadsheet document are groups of cells that are on the same horizontal line. Each row is identified by a number. For example, the first row has an index 1, the second one – 2 and the last one – 1048576.
2317

2418

25-
## IRowExporter Interface
19+
## IRowExporter and IRowImporter Interfaces
2620

2721
In **RadSpreadStreamProcessing**, a row could be exported through the [**IRowExporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.IRowExporter.html). It defines several methods allowing you to add cells to a row or change its appearance.
2822

23+
To read a row and its properties, you should use [**IRowImporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.IRowImporter.html).
24+
2925
### Using IRowExporter
3026

3127
A concrete instance of IRowExporter could be created through the CreateRowExporter() method of [IWorksheetExporter]({%slug radspreadstreamprocessing-model-worksheet%}). **Example 1** demonstrates how you can add a row to a worksheet.
@@ -79,6 +75,34 @@ In some cases you may need to skip several rows and start filling the data in th
7975
}
8076
{{endregion}}
8177

78+
## Read a Row
79+
80+
### Using IRowImporter
81+
82+
A concrete instance of IRowImporter could be obtained through the Rows collection of [IWorksheetImporter]({%slug radspreadstreamprocessing-model-worksheet%}). **Example 4** demonstrates how you can start reading a row from a worksheet.
83+
84+
#### **[C#] Example 4: Create IRowImporter**
85+
86+
{{region cs-radspreadstreamprocessing-model-rows_3}}
87+
88+
foreach (IRowImporter rowImporter in worksheetImporter.Rows)
89+
{
90+
}
91+
{{endregion}}
92+
93+
>IRowImporter inherits from [IDisposable](https://msdn.microsoft.com/en-us/library/system.idisposable(v=vs.110).aspx). Make sure the object is disposed when you are done with it. The best way to ensure this is handled properly is to wrap it in a *using* statement.
94+
95+
The IRowImporter interface exposes the following properties to allow you access its data:
96+
97+
* **RowIndex**: Gets the index of the row in the worksheet.
98+
* **OutlineLevel**: Gets the outline level (used when grouping rows).
99+
* **IsCustomHeight**: Gets a value indicating whether the height applied to the current row is a custom one.
100+
* **HeightInPixels** and **HeightInPoints**: Gets the height of the row in pixels and in points, respectively.
101+
* **IsHidden**: Gets a value determining whether the row is hidden.
102+
* **Cells**: Collection of ICellImporter objects, enabling you to iterate the cells inside the worksheet using.
103+
104+
105+
82106
## See Also
83107

84108
* [Columns]({%slug radspreadstreamprocessing-model-columns%})

libraries/radspreadstreamprocessing/model/workbook.md

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
title: Workbook
33
page_title: Workbook
44
slug: radspreadstreamprocessing-model-workbook
5-
tags: workbook
5+
tags: workbook, read, save
66
published: True
77
position: 1
88
---
@@ -11,25 +11,18 @@ position: 1
1111

1212
This article will help you get familiar with the concept of a workbook and its features.
1313

14-
* [What is a Workbook](#what-is-a-workbook)
15-
16-
* [IWorkbookExporter Interface](#iworkbookexporter-interface)
17-
18-
* [Using IWorkbookExporter](#using-iworkbookexporter)
19-
20-
2114
## What is a Workbook?
2215

2316
The workbook is the primary document that you use to manipulate and store data. The workbook can also be described as a collection of worksheets, where a worksheet is in turn defined as a collection of cells organized in rows and columns. Each workbook contains, at least, one worksheet and often holds several sheets with related information.
2417

2518
The workbook is designed to hold together multiple worksheets in order to allow efficient organization and consolidation of data. Typically, a workbook contains worksheets with related data.
2619

2720

28-
## IWorkbookExporter Interface
21+
## IWorkbookExporter and IWorkbookImporter Interfaces
2922

30-
In **RadSpreadStreamProcessing**, the workbook is represented by the [**IWorkbookExporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.IWorkbookExporter.html). This interface defines members for adding [worksheets]({%slug radspreadstreamprocessing-model-worksheet%}) and accessing the cell styles of the workbook.
23+
In **RadSpreadStreamProcessing**, the workbook is represented by the [**IWorkbookExporter**](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.IWorkbookExporter.html) and [**IWorkbookImporter** interface](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.IWorkbookImporter.html) interfaces. These interfaces define members for adding [worksheets]({%slug radspreadstreamprocessing-model-worksheet%}), parsing them, and accessing the cell styles of the workbook.
3124

32-
**IWorkbookExporter** is responsible for exporting a workbook. Due to the specifics of the different file formats, different concrete instances of this interface take care about the creation and export of a document.
25+
**IWorkbookExporter** is responsible for exporting a workbook. Due to the specifics of the different file formats, different concrete instances of this interface take care about the creation and export of a document. The same applies when importing with **IWorkbookImporter**.
3326

3427
## Using IWorkbookExporter
3528

@@ -83,7 +76,13 @@ Since the CSV format doesn't have the concept for multiple sheets, invoking GetS
8376

8477
>You can find a runnable example showing how to append a worksheet to an existing workbook in the [SDK repository](https://github.com/telerik/document-processing-sdk/tree/master/SpreadStreamProcessing/AppendWorksheetToExistingWorkbook) on GitHub.
8578
79+
## Using IWorkbookImporter to Read a File
80+
81+
The **IWorkbookImporter** interface is the entry point for reading a document and allows you iterate the worksheet importers. You can get an instance of IWorkbookImporter through the **CreateWorkbookImporter()** method of [SpreadExporter](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.SpreadExporter.html). The first parameter of the CreateWorkbookImporter() method specifies the file format of the document that will be imported and the second one represents the stream with the file data. For more information on how to read the data, check the [Import]({%slug radspreadstreamprocessing-import%}) help topic.
82+
83+
8684
## See Also
8785

86+
* [Import]({%slug radspreadstreamprocessing-import%})
8887
* [Worksheets]({%slug radspreadstreamprocessing-model-worksheet%})
8988
* [SpreadCellStyle API Reference](https://docs.telerik.com/devtools/document-processing/api/Telerik.Documents.SpreadsheetStreaming.SpreadCellStyle.html)

0 commit comments

Comments
 (0)