Spire.XLS is a professional Excel API that enables developers to create, manage, manipulate, convert and print Excel worksheets. Get free and professional technical support for Spire.XLS for .NET, Java, Android, C++, Python.

Tue Mar 25, 2025 9:14 am

I’m using Spire.XLS in VB.NET to extract and save images from an Excel file.
Some of the images in the Excel file have been edited using Excel’s "Crop" tool.
However, when I extract the images using the following code, the saved images are in their original (uncropped) form:

Dim savePath As String = Path.Combine(saveDirectory, fileName)
picture.Picture.Save(savePath, ImageFormat.Jpeg)

I would like to extract and save the cropped version of the images, exactly as they appear in the Excel sheet. Is there any way to achieve this using Spire.XLS? Or is there an alternative approach you recommend for extracting the image as it appears visually (after cropping)?

Thank you for your support.

CHUNHWANPARK
 
Posts: 1
Joined: Sat Feb 01, 2025 5:32 am

Wed Mar 26, 2025 2:54 am

Hello,

Thanks for your inquiry.
To achieve your needs, please use the following code to test. If you have any other questions, please feel free to write back.
Code: Select all
Dim workbook As New Workbook()
workbook.LoadFromFile("test.xlsx")
Dim sheet As Worksheet = workbook.Worksheets(0)
Dim picture As ExcelPicture = sheet.Pictures(0)
Dim bitmap As Bitmap = picture.SaveToImage()
bitmap.Save("res.png")

Sincerely,
William
E-iceblue support team
User avatar

William.Zhang
 
Posts: 732
Joined: Mon Dec 27, 2021 2:23 am

Return to Spire.XLS

cron