نطاق الدمج أو إلغاء الدمج Cells
Contents
[
Hide
]
يمكنك استخدام Aspose.Cells لدمج نطاق من الخلايا أو فصله. يوفر Aspose.Cells ملفRange.merge () وRange.unMerge () طرق لهذا الغرض. تشرح هذه المقالة كيفية دمج نطاق من الخلايا في خلية واحدة.
ينشئ نموذج التعليمات البرمجية التالي أولاً نطاقًا - A1: D4 - ثم يدمج الخلايا الموجودة في النطاق في خلية واحدة باستخدامRange.merge () طريقة. وبالمثل ، من الممكن تقسيم الخلايا عن طريق إنشاء نطاق واستدعاءRange.unMerge () طريقة.
تُظهر الصورة التالية ملف Excel الناتج الذي تم إنشاؤه باستخدام نموذج التعليمات البرمجية. كما ترى ، تم دمج النطاق A1: D4 في خلية واحدة.
This file contains 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
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
// The path to the documents directory. | |
String dataDir = Utils.getDataDir(MergeUnmergeRangeofCells.class); | |
// Create a workbook | |
Workbook workbook = new Workbook(); | |
// Access the first worksheet | |
Worksheet worksheet = workbook.getWorksheets().get(0); | |
// Create a range | |
Range range = worksheet.getCells().createRange("A1:D4"); | |
// Merge range into a single cell | |
range.merge(); | |
// Save the workbook | |
workbook.save(dataDir + "output.xlsx"); |