ByteScout Spreadsheet SDK - C# - Add Images - ByteScout

ByteScout Spreadsheet SDK – C# – Add Images

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

ByteScout Spreadsheet SDK – C# – Add Images

Program.cs

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

namespace AddImages
{
	class Program
	{
		static void Main(string[] args)
		{
			// Create spreadsheet
			Spreadsheet doc = new Spreadsheet();
			// Add worksheet
			Worksheet worksheet = doc.Worksheets.Add();

			// Put an image on the worksheet with 10 pixel margin from the top-left corner of the worksheet
			worksheet.Pictures.Add("image1.jpg", 10, 10);
			// Put second image to 200 pixel offset and resize it to 250x200 px
			worksheet.Pictures.Add("image2.jpg", 200, 200, 250, 200);

			// Delete output file if exists
			if (File.Exists("output.xls"))
			{
				File.Delete("output.xls");
			}

			// Save document
			doc.SaveAs("output.xls");

			// Close spreadsheet
			doc.Close();

			// Open generated XLS document in default application
			Process.Start("output.xls");

			doc.Dispose();
		}
	}
}


  Click here to get your Free Trial version of the SDK

Tutorials:

prev
next