Excel dosyalarına Resimler ve Şekiller Ekleyin.
Bazen çalışma sayfasına bazı gerekli şekiller eklemeniz gerekebilir. Aynı şekli çalışma sayfasının farklı konumlarına eklemeniz gerekebilir. Veya şekilleri toplu olarak çalışma sayfasına eklemeniz gerekebilir.
Endişelenmeyin! Aspose.Cells, tüm bu operasyonları destekler.
Bu rehber belgesi, örnek oluşturmak için her türden bir veya iki şekil seçecektir. Bu örnekler aracılığıyla, belirli şekli çalışma sayfasına eklemek için Aspose.Cells kullanmayı öğreneceksiniz.
- Resimler
- OleObjects
- Çizgiler
- Dikdörtgenler
- Temel Şekiller
- Blok Okları
- Denklem Şekilleri
- Akış Şemaları
- Yıldızlar ve Pankartlar
- Çağrılar
Bu rehber doküman, her türden bir veya iki şekil seçecek ve örnekler yapacaktır. Bu örnekler aracılığıyla, Aspose.Cells kullanarak belirtilen şekli çalışma tablosuna nasıl ekleyeceğinizi öğreneceksiniz.
C# ile Excel Çalışma Tablosuna Resim Ekleme
Bir elektron mikroskobuna resim eklemek çok kolaydır. Sadece birkaç satır kod gerektirir: Basitçe, pictures noktasal nesnesinde kapsüllenmiş olan Worksheet nesnesinin add metodunu çağırın. add metodu aşağıdaki parametreleri alır:
- üst_sol_satır, üst sol satırın dizini.
- üst_sol_sütun, üst sol sütunun dizini.
- dosya_adi, görüntü dosyasının adı, yol dahil.
from aspose.cells import Workbook | |
from os import os, path | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create directory if it is not already present. | |
IsExists = path.isdir(dataDir) | |
if notIsExists: | |
os.makedirs(dataDir) | |
# Instantiating a Workbook object | |
workbook = Workbook() | |
# Adding a new worksheet to the Workbook object | |
sheetIndex = workbook.worksheets.add() | |
# Obtaining the reference of the newly added worksheet by passing its sheet index | |
worksheet = workbook.worksheets[sheetIndex] | |
# Adding a picture at the location of a cell whose row and column indices | |
# Are 5 in the worksheet. It is "F6" cell | |
worksheet.pictures.add(5, 5, dataDir + "logo.jpg") | |
# Saving the Excel file | |
workbook.save(dataDir + "output.xls") |
C# ile Excel Çalışma Tablosuna OLE Nesneleri Eklemek
Aspose.Cells for Python via .NET, OLE nesnelerini çalışma sayfalarına ekleme, çıkarma ve manipüle etme desteği sağlar. Bu nedenle, Aspose.Cells for Python via .NET’de, koleksiyon listesine yeni bir OLE nesnesi eklemek için kullanılan OleObjectCollection sınıfı bulunur. Diğer bir sınıf olan OleObject, bir OLE nesnesini temsil eder. Bazı önemli üyeleri şunlardır:
- image_data özelliği, ikon olarak gösterilecek görüntü (ikon) verisini bayt dizisi türünde belirtir. Görüntü, çalışsayan elemanı çalışsayan eleman levhasında göstermek için kullanılacaktır.
- object_data özelliği, bayt dizisi biçimindeki nesne verisini belirtir. Bu veri, çalışsayan eleman simgesine çift tıkladığınızda ilgili programda gösterilecektir.
Aşağıdaki örnek, çalışsayan elemanları çalışsayan eleman(lar)ı çalışsayan eleman yapıştırma.
from aspose.cells import Workbook | |
from os import os, path | |
import bytearray | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# The path to the documents directory. | |
dataDir = RunExamples.GetDataDir(".") | |
# Create directory if it is not already present. | |
IsExists = path.isdir(dataDir) | |
if notIsExists: | |
os.makedirs(dataDir) | |
# Instantiate a new Workbook. | |
workbook = Workbook() | |
# Get the first worksheet. | |
sheet = workbook.worksheets[0] | |
# Define a string variable to store the image path. | |
ImageUrl = dataDir + "logo.jpg" | |
# Get the picture into the streams. | |
fs = open(ImageUrl, "rb") | |
# Define a byte array. | |
imageData = bytearray(utils.filesize(fs)) | |
# Obtain the picture into the array of bytes from streams. | |
fs.readinto(imageData) | |
# Close the stream. | |
fs.close() | |
# Get an excel file path in a variable. | |
path = dataDir + "book1.xls" | |
# Get the file into the streams. | |
fs = open(path, "rb") | |
# Define an array of bytes. | |
objectData = bytearray(utils.filesize(fs)) | |
# Store the file from streams. | |
fs.readinto(objectData) | |
# Close the stream. | |
fs.close() | |
# Add an Ole object into the worksheet with the image | |
# Shown in MS Excel. | |
sheet.ole_objects.add(14, 3, 200, 220, imageData) | |
# Set embedded ole object data. | |
sheet.ole_objects[0].object_data = objectData | |
# Save the excel file | |
workbook.save(dataDir + "output.out.xls") |
C# ile Excel Çalışma Tablosuna Çizgi Eklemek
Satırın şekli çizgiler kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Satırı eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Ardından, ‘Son Kullanılan Şekiller’ veya ‘Çizgiler’den satırı seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına bir satır eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Aşağıdaki örnek, bir çalışma sayfasına satır eklemenin nasıl yapılacağını göstermektedir.
from aspose.cells import SaveFormat, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the line to the worksheet | |
sheet.shapes.add_line(2, 0, 2, 0, 100, 300) | |
# sheet.Shapes.AddAutoShape(AutoShapeType.Line, 2, 0, 2, 0, 100, 300);# method 2 | |
# sheet.Shapes.AddShape(MsoDrawingType.Line, 2, 0, 2, 0, 100, 300);# method 3 | |
# Save.You can check your line in this way. | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# ile Excel Çalışma Kitabına Satır Oku Eklemek
Satırın oku şekli Çizgiler kategorisine aittir. Bu, bir satırın özel bir durumudur.
Microsoft Excel’de (örneğin 2007):
- Ok satırını eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Ardından, ‘Son Kullanılan Şekiller’ veya ‘Çizgiler’den ok satırını seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına bir ok satırı eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Aşağıdaki örnek, bir çalışma sayfasına ok satırı eklemenin nasıl yapılacağını göstermektedir.
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import MsoArrowheadLength, MsoArrowheadStyle, MsoArrowheadWidth | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the line arrow to the worksheet | |
s = sheet.shapes.add_line(2, 0, 2, 0, 100, 300) | |
# Shape s = sheet.Shapes.AddAutoShape(AutoShapeType.Line, 2, 0, 2, 0, 100, 300);# method 2 | |
# Shape s = sheet.Shapes.AddShape(MsoDrawingType.Line, 2, 0, 2, 0, 100, 300);# method 3 | |
# add a arrow at the line begin | |
s.line.begin_arrowhead_style = MsoArrowheadStyle.ARROW | |
s.line.begin_arrowhead_width = MsoArrowheadWidth.WIDE | |
s.line.begin_arrowhead_length = MsoArrowheadLength.SHORT | |
# add a arrow at the line end | |
s.line.end_arrowhead_style = MsoArrowheadStyle.ARROW_OPEN | |
s.line.end_arrowhead_width = MsoArrowheadWidth.NARROW | |
s.line.end_arrowhead_length = MsoArrowheadLength.LONG | |
# Save.You can check your arrow in this way. | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# ile Excel Çalışma Kitabına Dikdörtgen Eklemek
Dikdörtgenin şekli Dikdörtgenler kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Dikdörtgeni eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Ardından, ‘Son Kullanılan Şekiller’ veya ‘Dikdörtgenler’den dikdörtgeni seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına bir dikdörtgen eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Yöntem, bir RectangleShape nesnesi döndürür.
Aşağıdaki örnek, bir çalışma sayfasına dikdörtgen nasıl ekleyeceğinizi gösterir.
from aspose.cells import SaveFormat, Workbook | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the rectangle to the worksheet | |
sheet.shapes.add_rectangle(2, 0, 2, 0, 100, 300) | |
# Save | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# ile Excel Çalışma Kitabına Küp Eklemek
Küpün şekli Temel Şekiller kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Küpü eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Sonra, Temel Şekiller‘den Küp’ü seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına bir küp eklemek için aşağıdaki yöntemi kullanabilirsiniz.
public Shape add_auto_shape(type, upper_left_row, top, upper_left_column, left, height, width)
Yöntem, bir Shape nesnesi döndürür.
Aşağıdaki örnek, bir çalışma sayfasına küp nasıl ekleyeceğinizi gösterir.
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import AutoShapeType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the cube to the worksheet | |
sheet.shapes.add_auto_shape(AutoShapeType.CUBE, 2, 0, 2, 0, 100, 300) | |
# Save.You can check your cube in this way. | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# ile Excel Çalışma Sayfasına Çağrı Oku Ok İçin Ekleme
Çağrı oku dört ok şekli Bloklı Oklar kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Çağrı ok dört ok eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Sonra, Bloklı Oklar‘dan çağrı ok dört ok’u seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına bir çağrı oku dört ok eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Yöntem, bir Shape nesnesi döndürür.
Aşağıdaki örnek, bir çalışma sayfasına çağrı ok dört ok nasıl ekleyeceğinizi gösterir.
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import AutoShapeType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the callout quad arrow to the worksheet | |
sheet.shapes.add_auto_shape(AutoShapeType.QUAD_ARROW_CALLOUT, 2, 0, 2, 0, 100, 100) | |
# Save | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# ile Excel Çalışma Sayfasına Çarpı İşareti Ekleme
Çarpma işareti şekli Denklem Şekilleri kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Çarpma işareti eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Sonra, Denklem Şekilleri‘nden çarpma işaretini seçin
Aspose.Cells for Python via .NET kullanılarak
Çarpma işaretini çalışma sayfasına eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Yöntem, bir Shape nesnesi döndürür.
Aşağıdaki örnek, bir çalışma sayfasına çarpma işareti eklemeyi göstermektedir.
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import AutoShapeType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the multiplication sign to the worksheet | |
sheet.shapes.add_auto_shape(AutoShapeType.MATH_MULTIPLY, 2, 0, 2, 0, 100, 100) | |
# Save.You can check your multiplication in this way. | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# ile Excel Çalışma Sayfasına Çoklu Belge Ekleme
Çoklu belgenin şekli FlowCharts kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Çoklu belgeyi eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Sonra, FlowCharts‘den çoklu belgeyi seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına çoklu belge eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Yöntem, bir Shape nesnesi döndürür.
Aşağıdaki örnek, bir çalışma sayfasına çoklu belge eklemeyi göstermektedir.
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import AutoShapeType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the multidocument to the worksheet | |
sheet.shapes.add_auto_shape(AutoShapeType.FLOW_CHART_MULTIDOCUMENT, 2, 0, 2, 0, 100, 100) | |
# Save | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# Dilinde Excel Çalışma Sayfasına Beşgen Yıldız Ekleme
Beş köşeli yıldızın şekli Yıldızlar ve Bayraklar kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Beş köşeli yıldızı eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Sonra, Yıldızlar ve Bayraklar‘dan beş köşeli yıldızı seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına beş köşeli yıldız eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Yöntem, bir Shape nesnesi döndürür.
Aşağıdaki örnek, bir çalışma sayfasına beş köşeli yıldız eklemeyi göstermektedir.
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import AutoShapeType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the Five-pointed star to the worksheet | |
sheet.shapes.add_auto_shape(AutoShapeType.STAR5, 2, 0, 2, 0, 100, 100) | |
# Save.You can check your icon in this way. | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
C# Dilinde Excel Çalışma Sayfasına Düşünce Balonu Bulutu Ekleme
Düşünce balonu bulutunun şekli Çağrılar kategorisine aittir.
Microsoft Excel’de (örneğin 2007):
- Düşünce balonu bulutu eklemek istediğiniz hücreyi seçin
- Insert menüsünü tıklayın ve Şekiller’e tıklayın.
- Daha sonra, Araç Çubuğu‘ndan düşünce balonu bulutunu seçin
Aspose.Cells for Python via .NET kullanılarak
Çalışma sayfasına düşünce balonu bulutu eklemek için aşağıdaki yöntemi kullanabilirsiniz.
Yöntem, bir Shape nesnesi döndürür.
Aşağıdaki örnek, bir çalışma sayfasına düşünce balonu bulutu nasıl ekleyeceğinizi gösterir.
from aspose.cells import SaveFormat, Workbook | |
from aspose.cells.drawing import AutoShapeType | |
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET | |
# Create workbook from sample file | |
workbook = Workbook() | |
# Access first worksheet from the collection | |
sheet = workbook.worksheets[0] | |
# Add the thought bubble cloud to the worksheet | |
sheet.shapes.add_auto_shape(AutoShapeType.CLOUD_CALLOUT, 2, 0, 2, 0, 100, 100) | |
# Save | |
workbook.save("sample.xlsx", SaveFormat.XLSX) |
Yukarıdaki kodu çalıştırın, aşağıdaki sonuçları elde edersiniz:
Gelişmiş Konular
- Şekil Ayar Değerlerini Değiştirme
- Çalışma Sayfaları Arasında Şekilleri Kopyalama
- İlkel Olmayan Şekildeki Veri
- Çalışma Sayfası İçindeki Şeklin Mutlak Konumunu Bulma
- Şekilden Bağlantı Noktalarını Al
- Denetimleri Yönetme
- Çalışma Sayfasına Simgeler Ekleme
- OLE Nesnelerini Yönetme
- Resimleri Yönetme
- Akıllı Sanatı Yönetme
- Metin Kutularını Yönetme
- Çalışma Sayfasına WordArt Fili Ekleme
- Bağlantılı Şekillerin Değerlerini Yenileme
- Çalışma Sayfası İçinde Şekil Önüne veya Arkasına Gönderme
- Şekil Seçeneklerini Yönetme
- Şekil Metin Seçeneklerini Yönetme
- Web Uzantıları - Office Eklentileri