using iDiTect.Excel.Drawings;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace iDiTect.Excel.Demo
{
    public static class PictureHelper
    {
        public static void InsertPictureToSheet()
        {
            var workbook = new Workbook();
            var worksheet = workbook.Worksheets.Add("PictureSheet");

            ///Insert image from file
            var picture = worksheet.AddPicture("demo-pic.png", "imageFromFile");
            //Set image position with absolute point
            picture.SetPosition(100, 100);
            //Set image size, if not set, the image will be shown as original size
            picture.SetSize(200, 50);

            ///Insert image from stream
            using (Stream stream = File.OpenRead("demo-pic2.jpg"))
            {
                var picture2 = worksheet.AddPicture(stream, PictureFormat.Jpeg);
                //Set image position to cell
                picture2.SetPosition(worksheet.Cell("A10"));
                //Set image placement
                picture2.SetPlacement(PicturePlacement.Move);
            }

            workbook.Save("Picture.xlsx");
        }




    }
}
