ByteScout Spreadsheet SDK – VB.NET – Add Images Advanced

  • Home
  • /
  • Articles
  • /
  • ByteScout Spreadsheet SDK – VB.NET – Add Images Advanced

ByteScout Spreadsheet SDK – VB.NET – Add Images Advanced


Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.IO
Imports System.Text
Imports Bytescout.Spreadsheet
Imports Bytescout.Spreadsheet.MSODrawing

Namespace AddImages
	Class Program
		Friend Shared Sub Main(args As String())
			' Create spreadsheet
			Dim doc As New Spreadsheet()
			' Add worksheet
			Dim worksheet As Worksheet = doc.Worksheets.Add()

			' Put an image to "C3" cell
			Dim shape As PictureShape = worksheet.Pictures.Add(2, 2, "image1.jpg")

			' Make the picture "floating". It will be not moved if you move or resize the "C3" cell
			shape.PlacementType = Placement.FreeFloating

			' Make the picture brighter
			shape.Brightness = 0.8F

			' Put second image to "K11" cell
			shape = worksheet.Pictures.Add(10, 10, "image2.jpg")

			' Make the picture bound to the cell. It will be moved alonf with the "K11" cell
			shape.PlacementType = Placement.Move

			' Crop 10% from left and right side of the image
			shape.CropFromLeft = 0.1F
			shape.CropFromRight = 0.1F

			' Delete output file if exists
			If File.Exists("output.xls") Then
			End If

			' Save document

			' Close spreadsheet

			' Open generated XLS document in default application

		End Sub
	End Class
End Namespace

  Click here to get your Free Trial version of the SDK