دمج أو إلغاء دمج نطاق الخلايا باستخدام C++

Contents
[ ]

مثال

يعرض الكود النموذجي التالي أولاً إنشاء نطاق - A1:D4 - ثم دمج الخلايا في النطاق إلى خلية واحدة باستخدام الطريقة Range.Merge(). بالمثل، يمكنك تقسيم الخلايا عن طريق إنشاء نطاق واستدعاء الطريقة Range.UnMerge().

#include <iostream>
#include "Aspose.Cells.h"
using namespace Aspose::Cells;

int main()
{
    Aspose::Cells::Startup();

    // For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-C

    // Source directory path
    U16String srcDir(u"..\\Data\\01_SourceDirectory\\");

    // Path of output excel file
    U16String outputPath = srcDir + u"output.out.xlsx";

    // Create a workbook
    Workbook workbook;

    // Access the first worksheet
    Worksheet worksheet = workbook.GetWorksheets().Get(0);

    // Create a range
    Range range = worksheet.GetCells().CreateRange(u"A1:D4");

    // Merge range into a single cell
    range.Merge();

    // Save the workbook
    workbook.Save(outputPath);

    std::cout << "Workbook saved successfully!" << std::endl;

    Aspose::Cells::Cleanup();
}