نسخ ارتفاعات الصف من النطاق المصدر إلى النطاق الوجهة
Contents
[
Hide
]
في بعض الأحيان يحتاج المستخدم إلى نسخ أطوال الصفوف من نطاق المصدر إلى نطاق الوجهة. Aspose.Cells لمكتبة Python via .NET توفر: PasteType.ROW_HEIGHTS enum لهذا الغرض. عند تعيين PasteOptions.paste_type property بـ PasteType.ROW_HEIGHTS enum فإن أطوال جميع الصفوف داخل نطاق المصدر ستتم نسخها إلى نطاق الوجهة.
يوضح الكود العيني التالي كيفية استخدام enum PasteType.ROW_HEIGHTS لنسخ ارتفاعات الصف من نطاق المصدر إلى نطاق الوجهة. بمجرد فتح ملف إكسل الناتج الذي تم إنشاؤه بواسطة هذا الكود في Microsoft Excel، سترى أن ارتفاعات صفوف نطاق الوجهة تطابق تمامًا مع ارتفاعات صفوف نطاق المصدر.
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
from aspose.cells import PasteOptions, PasteType, SaveFormat, Workbook | |
# 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(".") | |
# Create workbook object | |
workbook = Workbook() | |
# Source worksheet | |
srcSheet = workbook.worksheets[0] | |
# Add destination worksheet | |
dstSheet = workbook.worksheets.add("Destination Sheet") | |
# Set the row height of the 4th row. This row height will be copied to destination range | |
srcSheet.cells.set_row_height(3, 50) | |
# Create source range to be copied | |
srcRange = srcSheet.cells.create_range("A1:D10") | |
# Create destination range in destination worksheet | |
dstRange = dstSheet.cells.create_range("A1:D10") | |
# PasteOptions, we want to copy row heights of source range to destination range | |
opts = PasteOptions() | |
opts.paste_type = PasteType.ROW_HEIGHTS | |
# Copy source range to destination range with paste options | |
dstRange.copy(srcRange, opts) | |
# Write informative message in cell D4 of destination worksheet | |
dstSheet.cells.get("D4").put_value("Row heights of source range copied to destination range") | |
# Save the workbook in xlsx format | |
workbook.save(dataDir + "output_out.xlsx", SaveFormat.XLSX) |