ByteScout Spreadsheet SDK - C# - Add Image - ByteScout
Announcement
Our ByteScout SDK products are sunsetting as we focus on expanding new solutions.
Learn More Open modal
Close modal
Announcement Important Update
ByteScout SDK Sunsetting Notice
Our ByteScout SDK products are sunsetting as we focus on our new & improved solutions. Thank you for being part of our journey, and we look forward to supporting you in this next chapter!

ByteScout Spreadsheet SDK – C# – Add Image

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – C# – Add Image

ByteScout Spreadsheet SDK – C# – Add Image

Program.cs

using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.IO;
using Bytescout.Spreadsheet;

namespace CSharp
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
			    // create new Spreadsheet object
                Spreadsheet spreadsheet = new Spreadsheet();

                // add new worksheet
                Worksheet sheet = spreadsheet.Workbook.Worksheets.Add("Sample");

                // add a picture to worksheet
                sheet.Pictures.Add("image.jpg", 100, 100);
                sheet.Cell("A1").ValueAsHTML = "<b>Image from</b> from <i>Image.jpg</i>";
			
                if(File.Exists("Output.xls")){
                    File.Delete("Output.xls");
                }
                
                // Save it as XLS
                spreadsheet.SaveAs("Output.xls");

                // close the document
                spreadsheet.Close();

                // open output XLS
                Process.Start("Output.xls");


            }
            catch(Exception e){
                Console.WriteLine("CAN NOT EXECUTE: " + e.ToString());
                Console.WriteLine("\nPress any key to exit");
                Console.ReadKey();
            }

        }
    }
}


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next