The following section shows how to insert a picture / image / icon in an .xlsx spreadsheet file from C# Application .
Support commonly used image format, such as .Jpeg, .Png, .Bmp, .Tiff, .Gif and .ico
Read picture from local file.
var picture = worksheet.AddPicture("demo-pic.png", "imageFromFile");
Read picture from stream (file stream or momery stream).
var picture2 = worksheet.AddPicture(stream, PictureFormat.Jpeg);
Set image position with absolute point.
picture.SetPosition(100, 100);
Or insert image to target cell.
picture2.SetPosition(worksheet.Cell("A10"));
Allows to change image size to any width and height. If you want to keep the original image size, just not calling the SetSize() method.
picture.SetSize(200, 50);
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");
We provide powerful & profession document & image controls: How to convert html to pdf in c# Convert any web page to PDF using a powerful tool: iDiTect.Converter Html to Pdf Converter for .NET Convert HTML to Well-Formatted Microsoft Word Convert HTML to / from Word (DOCX) document in C# and VB.NET with iDiTect.Converter component. C# - Generate and save a PDF file you can use a PDF library, load your PDF form, set the values to each field, flatten your file Read and Extract PDF Text from C# / VB.NET applications how to extract all text from PDF file into TXT file (plain text) using PDF Extractor SDK. C#.NET Word to Image Converter SDK Convert Docx Word file into editable images using C# Able to convert multi-page Word document to separate image files by C# programming code. Programmatically convert MS Word DOCX files to PDF in C# A few lines of C# code are all it takes to convert Word to PDF for your .NET application.