إعداد الروابط الخارجية في الصيغ باستخدام ++C
Contents
 [
      
        Hide
      ]
    
في بعض الأحيان، من الضروري تضمين روابط إلى ملفات خارجية في الصيغ، على سبيل المثال، لتقييم قيمة خلية أو نطاق مقابلها. يوفر Aspose.Cells هذه الميزة ويوضح هذا المستند كيفية استخدامها.
يظهر الكود النموذجي أدناه كيفية تضمين الملفات الخارجية في الصيغ.
#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;
int main()
{
    Aspose::Cells::Startup();
    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");
    // Output directory path
    U16String outDir(u"..\\Data\\02_OutputDirectory\\");
    // Instantiate a new Workbook
    Workbook workbook;
    // Get first Worksheet
    Worksheet sheet = workbook.GetWorksheets().Get(0);
    // Get Cells collection
    Cells cells = sheet.GetCells();
    // Set formula with external links
    cells.Get(u"A1").SetFormula(U16String(u"=SUM('[") + srcDir + u"book1.xlsx]Sheet1'!A2, '[" + srcDir + u"book1.xlsx]Sheet1'!A4)");
    // Set formula with external links
    cells.Get(u"A2").SetFormula(U16String(u"='[") + srcDir + u"book1.xlsx]Sheet1'!A8");
    // Save the workbook
    workbook.Save(outDir + u"output_out.xlsx");
    std::cout << "Workbook saved successfully with external links!" << std::endl;
    Aspose::Cells::Cleanup();
}