Çalışma Sayfasına Simgeler Ekleme

Aspose.Cells for Python via .NET ile Çalışma Sayfasına Simge Ekleme

Eğer Excel dosyanıza ‘simge’ler eklemek için Aspose.Cells for Python via .NET kullanmanız gerekiyorsa, bu belge size yardımcı olabilir.

Ekle simgesine karşılık gelen Excel arayüzü aşağıdaki gibidir:

  • Çalışma sayfasına eklemek istediğiniz simgenin konumunu seçin
  • Ekle->Simgelerü tıklayın
  • Açılan pencerede, yukarıdaki resimde kırmızı dikdörtgen içindeki simgeyi seçin
  • Excel dosyasına eklenecek, Ekle butonuna sol tıklayın.

Efekt aşağıdaki gibidir:

Burada, Aspose.Cells for Python via .NET kullanarak simge eklemenize yardımcı olacak örnek kod hazırladık. Ayrıca, gerekli örnek dosya ve bir simge kaynak dosyası bulunmaktadır. Excel arayüzünü kullanarak, kaynak dosyası ile aynı görsel etkiyi sağlayan bir simgeyi örnek dosya içine ekledik.

Python Örnek Kodu

from aspose import pycore
from aspose.cells import SaveFormat, Workbook
from aspose.pydrawing import Color
import bytearray
import int
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Read icon resource file data
fileName = "icon.svg"
fsSource = open(fileName, "rb")
bytes = bytearray(utils.filesize(fsSource))
numBytesToRead = pycore.cast(int, utils.filesize(fsSource))
numBytesRead = 0
while numBytesToRead > 0:
# Read may return anything from 0 to numBytesToRead.
n = fsSource.readinto(bytes)
# Break when the end of the file is reached.
if n == 0:
break
numBytesRead = n
numBytesToRead = n
fsSource.close()
# Create workbook from sample file
workbook = Workbook("sample.xlsx")
# Access first worksheet from the collection
sheet = workbook.worksheets[0]
# Add the icon to the worksheet
sheet.shapes.add_icons(3, 0, 7, 0, 100, 100, bytes, None)
# Set a prompt message
c = sheet.cells.get(8, 7)
c.value = "Insert via Aspose.Cells"
s = c.get_style()
s.font.color = Color.blue
c.set_style(s)
# Save.You can check your icon in this way.
workbook.save("sample2.xlsx", SaveFormat.XLSX)

Yukarıdaki kodu projenizde çalıştırdığınızda aşağıdaki sonuçları elde edersiniz: