C#-Read Image from Excel

In the last post, I show the method to write image in an Excel file. But, if I want to read image from one Excel file in a form via Spire.XLS, how should I do?

Firstly, we need to create a project as usual. I name it ReadImage.

Secondly, add references: Spire.XLS, System.Drawing, System.Windows.Forms (we need to show image in one form).

In this example, the image I will read is from another Excel file which I have in my computer, not the file I generate last time.

Then, use the following code.

using System.Drawing;
using System.Windows.Forms;
using Spire.Xls;

namespace ExcelSample
    class ReadImage
        static void Main(string[] args)
            Workbook workbook = new Workbook();
            Worksheet sheet = workbook.Worksheets[0];

            ExcelPicture pic = sheet.Pictures[0];

            Form frm1 = new Form();
            PictureBox pic1 = new PictureBox();
            pic1.Image = pic.Picture;
            frm1.Width = pic.Picture.Width;
            frm1.Height = pic.Picture.Height;
            frm1.StartPosition = FormStartPosition.CenterParent;
            pic1.Dock = DockStyle.Fill;

After running, we can get the result as following:


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s