Aşağıdaki kodu kullanarak ByteScout Spreadsheet SDK ile oluşturulan XLX/XLSX tabloları içine görüntüleri ve grafikler ekleyebilir: Visual Basic .NET
:
Imports System.Collections.Generic
Imports System.Diagnostics
Imports System.IO
Imports System.Text
Imports Bytescout.Spreadsheet
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 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)
' Save document
doc.SaveAs("output.xls")
' Close spreadsheet
doc.Close()
' Open generated XLS document in default application
Process.Start("output.xls")
doc.Dispose()
End Sub
End Class
Ve C#:
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using Bytescout.Spreadsheet;
using Bytescout.Spreadsheet.MSODrawing;
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 to "C3" cell
PictureShape shape = 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 along 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;
// Save document
doc.SaveAs("output.xls");
// Close spreadsheet
doc.Close();
// Open generated XLS document in default application
Process.Start("output.xls");
doc.Dispose();
}
}
}
Daha fazla kod örneği için, yeni ve exis'e görüntü ekleme gibi işlevleri kapsayan daha fazla kaynak kodu örneği için Spreadsheet SDK online documentation - * Gelişmiş Örnekler .. * bölümüne göz atın. e-tablolar, grafikler ve diğerleri ekleyerek.
bakınız [bu] (http://www.gemboxsoftware.com/SampleExplorer/Spreadsheet/BasicFeatures/Images), örnek yeni bir dosya excel ve http ([GemBox.Spreadsheet] ile kendisine resim eklemek nasıl oluşturulacağını gösterir : //www.gemboxsoftware.com/spreadsheet/overview) kütüphanesi. –
Cevabınız için teşekkür ederiz. Ben ona bakacağım. –