Inserimento di un file WAV come Oggetto OLE
Contents
[
Hide
]
Aspose.Cells per Python via .NET fornisce la funzionalità di aggiungere diversi tipi di oggetti OLE ai fogli di calcolo Excel. Vedremo negli esempi di codice seguenti come aggiungere un file wav come oggetto OLE usando API semplici fornite da Aspose.Cells for Python via .NET.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from aspose.cells import FileFormatType, Workbook | |
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(".") | |
# Define a string variable to store the image path. | |
ImageUrl = dataDir + "image2.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 + "chord.wav" | |
# 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() | |
intIndex = 0 | |
# Instantiate a new Workbook. | |
workbook = Workbook() | |
sheet = workbook.worksheets[0] | |
# Add Ole Object | |
sheet.ole_objects.add(14, 3, 200, 220, imageData) | |
workbook.worksheets[0].ole_objects[intIndex].file_format_type = FileFormatType.UNKNOWN | |
workbook.worksheets[0].ole_objects[intIndex].object_data = objectData | |
workbook.worksheets[0].ole_objects[intIndex].object_source_full_name = path | |
# Save the excel file | |
workbook.save(dataDir + "testWAV.out.xlsx") |