Skip to content

Commit ee97ee2

Browse files
author
KB Bot
committed
Added new kb article spreadsheet-export-floatingimage
1 parent 72109a5 commit ee97ee2

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
title: Exporting FloatingImage from RadSpreadsheet Worksheet
3+
description: Learn how to save an image from a RadSpreadsheet worksheet as a file.
4+
type: how-to
5+
page_title: How to Save a FloatingImage from RadSpreadsheet Worksheet as an Image File
6+
slug: radspreadsheet-export-floatingimage
7+
tags: spreadsheet, winforms, workbook, worksheet, image, export, file
8+
res_type: kb
9+
ticketid: 1672191
10+
---
11+
12+
## Environment
13+
14+
|Product Version|Product|Author|
15+
|----|----|----|
16+
|2024.4.1113|RadSpreadsheet for WinForms|[Dinko Krastev](https://www.telerik.com/blogs/author/dinko-krastev)|
17+
18+
## Description
19+
20+
To export an image (represented as a `FloatingImage` object) inside the Worksheet, you can use the `ImageSource.Data` property of the `FloatingImage` object. This property exposes the image as a byte array, which you can then export using the `File.WriteAllBytes()` method. Follow the steps below to achieve this:
21+
22+
Here is an example code snippet demonstrating how to perform these steps:
23+
24+
````C#
25+
using System.IO;
26+
27+
var worksheet = this.radSpreadsheet1.Workbook.Sheets[0] as Worksheet;
28+
29+
// Access the first FloatingImage object from the worksheet's Images collection
30+
var floatingImage = worksheet.Images[0];
31+
32+
// Export the image
33+
File.WriteAllBytes($"../../image.{floatingImage.ImageSource.Extension}", floatingImage.ImageSource.Data);
34+
35+
````
36+
37+
This code saves the first image found in the worksheet's `Images` collection. You can modify the file path and name as needed. Additionally, ensure the extension matches the image format for correct file handling.
38+
39+
## See Also
40+
* [RadSpreadsheet Documentation](https://docs.telerik.com/devtools/winforms/controls/radspreadsheet/overview)
41+
* [Worksheet Images Collection Overview](https://docs.telerik.com/devtools/winforms/controls/radspreadsheet/model/images)

0 commit comments

Comments
 (0)