Bu konu C# kullanarak PowerPoint Tablosuna Görüntü ekleme konusuna odaklanmaktadır. Ortamı oluşturmak için tüm ayrıntıları, bir tablo hücresini bir görüntüyle oluşturmak ve doldurmak için adım adım bir prosedürü ve C#’ta ** PPTX Tablosuna nasıl resim ekleneceğini gösteren çalışma örneğini içerir . Geliştirilen uygulama, Windows, macOS veya Linux gibi .NET ile yapılandırılmış herhangi bir ortamda kullanılabilir.
C# kullanarak PowerPoint Tablosuna Resim Ekleme Adımları
- Tablo resmi eklemek için Aspose.Slides for .NET eklemek için ortamı ayarlayın
- Yeni bir sunum eklemek ve slayt koleksiyonundan ilk slayda erişmek için Presentation sınıf nesnesinin örneğini oluşturun
- AddTable() yöntemini kullanarak, seçili slayda satırlar ve sütunlar için belirli yüksekliklere sahip bir tablo ekleyin
- İstenilen görüntüyü sunum görseli koleksiyonunun içine yerleştirin
- Tablodan ilk satır ve sütuna ait hücreye erişin ve eklenen görüntüyü bu hücrenin içine ayarlayın.
- Sunumu tablo görüntüsüyle birlikte PPTX biçiminde kaydedin
Yukarıdaki adımlarda, C# dilinde PPTX Tablosunda görüntünün nasıl görüntüleneceğini açıkladık. Süreç, Presentation sınıfının bir örneğini kullanarak varsayılan bir sunum oluşturarak ve ilk slaydına erişim sağlayarak başlayacaktır. Sonraki adımlarda, tablo için satır ve sütun sayısını sağlayarak AddTable() yöntemini kullanarak yeni bir tablo ekleyeceğiz, ardından kaynak görüntüyü yükleyip sunum görüntü koleksiyonunun içine ekleyeceğiz. Son olarak, tablodan istenen hücre seçilecek ve çıktı sunumunu diske kaydetmeden önce yüklenen görüntü o hücre için ayarlanacaktır.
C# kullanarak PowerPoint Tablosuna Görüntü Ekleme Kodu
using System.Drawing; | |
using Aspose.Slides; | |
namespace TestSlides | |
{ | |
public class InsertImageInTable | |
{ | |
public static void AddImageInsideTable() | |
{ | |
string filesPath = @"/Users/Documents/KnowledgeBase/TestData/"; | |
License license = new License(); | |
license.SetLicense(filesPath + "Conholdate.Total.Product.Family.lic"); | |
//Create a new presentation to insert an image inside the table | |
Presentation TablePresentation = new Presentation(); | |
//Load the first default slide of the presentation | |
ISlide targetSlide = TablePresentation.Slides[0]; | |
// Access the source image from the disk and add to presentation images | |
System.Drawing.Image tblImage = (System.Drawing.Image)new Bitmap(filesPath+ "Test.png"); | |
IPPImage ppTblImage = TablePresentation.Images.AddImage(tblImage); | |
//Now declare the rows heights and columns widths | |
double[] columnsWidths = { 45, 45, 45 ,45}; | |
double[] rowsHeights = { 45, 26, 30, 30 }; | |
// Insert a table inside the slide | |
Aspose.Slides.ITable tableWithImage = targetSlide.Shapes.AddTable(55, 55, columnsWidths, rowsHeights); | |
// Access the first cells inside the first row of the table | |
ICell tableCell = tableWithImage[0,0]; | |
// Set the cell fill format to picture | |
tableCell.CellFormat.FillFormat.FillType = FillType.Picture; | |
// Set the picture fill mode | |
tableCell.CellFormat.FillFormat.PictureFillFormat.PictureFillMode = PictureFillMode.Stretch; | |
// Set the image for the selected cell inside the table | |
tableCell.CellFormat.FillFormat.PictureFillFormat.Picture.Image = ppTblImage; | |
//Save the presentation with the table image on the disk | |
TablePresentation.Save(filesPath + "PresWithTableImage.pptx", Aspose.Slides.Export.SaveFormat.Pptx); | |
} | |
} | |
} |
Bu konuda, C# kullanarak bir Sunuma tablo görüntüsünü nasıl ekleyeceğiniz konusuna odaklandık. PowerPoint içindeki tabloları yönetmeyle ilgili öğreniminizi daha da geliştirmek istiyorsanız, C# kullanarak PowerPoint’te Tablo Oluşturma başlıklı makaleye bakın.