C++ ile Web URL den Excel Çalışma Sayfasına Web Görseli yükleyin
Contents
[
Hide
]
Bir URL’den Bir Resmi Excel Çalışma Sayfasına Yükleme
Aspose.Cells for C++ API, URL’lerden Excel Çalışma Sayfalarına resim yükleme konusunda basit bir yöntem sağlar. Bu makale, görsel verilerini bellek akışına indirip Aspose.Cells kullanarak çalışma sayfasına eklemeyi açıklar. Resim, Excel dosyasına gömülü hale gelir ve açılırken harici indirmeler gerekmez.
Örnek Kod
#include <iostream>
#include <Aspose.Cells.h>
using namespace Aspose::Cells;
int main()
{
Aspose::Cells::Startup();
// Source and output directories
U16String srcDir(u"../Data/01_SourceDirectory/");
U16String outDir(u"../Data/02_OutputDirectory/");
try
{
// Create a new workbook
Workbook wb;
// Get the first worksheet
WorksheetCollection worksheets = wb.GetWorksheets();
Worksheet sheet = worksheets.Get(0);
// Get the pictures collection
PictureCollection pictures = sheet.GetPictures();
// Insert the picture from local file to B2 cell (row 1, column 1)
// Note: Image file should be pre-downloaded to source directory
U16String imagePath = srcDir + u"aspose-logo.jpg";
pictures.Add(1, 1, imagePath);
// Save the Excel file
wb.Save(outDir + u"webimagebook.out.xlsx");
std::cout << "Image added successfully." << std::endl;
}
catch (const std::exception& ex)
{
std::cerr << "Error: " << ex.what() << std::endl;
return 1;
}
Aspose::Cells::Cleanup();
return 0;
}
Her zaman güncellenen URL’den resim gerektiren durumlar için, Web Adresinden Bağlantılı Resim Ekle metodunu kullanın. Bu yöntem, çalışma sayfası her açıldığında URL’den resmi yükler.