نسخ ونقل ورقات العمل

كيفية نقل أو نسخ الأوراق باستخدام برنامج مايكروسوفت إكسل

فيما يلي الخطوات اللازمة لنسخ ونقل أوراق العمل داخل أو بين دفاتر العمل في Microsoft Excel.

  1. لنقل أو نسخ الأوراق إلى دفتر العمل الآخر، افتح دفتر العمل الذي سيتلقى الأوراق.
  2. انتقل إلى دفتر العمل الذي يحتوي على الأوراق التي ترغب في نقلها أو نسخها، ثم حدد الأوراق.
  3. في قائمة تحرير، انقر فوق نقل أو نسخ الصفحة.
  4. في مربع الحوار إلى مصنف، انقر فوق المصنف الذي سيستقبل الصفحات.
  5. لنقل أو نسخ الصفحات المحددة إلى مصنف جديد، انقر فوق مصنف جديد.
  6. في مربع قبل الصفحة، انقر فوق الصفحة التي ترغب في إدراج الصفحات المنقولة أو المنسوخة قبلها.
  7. لنسخ الصفحات بدلاً من نقلها، حدد مربع الاختيار إنشاء نسخة.

كيفية نسخ أوراق العمل ضمن مصنف بمكتبة Aspose.Cells للبايثون لإكسيل

يوفر Aspose.Cells للبايثون via .NET طريقة زائدة، Aspose.Cells.WorksheetCollection.add_copy()، تُستخدم لإضافة ورقة عمل إلى المجموعة ونسخ البيانات من ورقة العمل الموجودة. إصدار من الطريقة يأخذ فهرس ورقة العمل المصدر كمعلمة. الإصدار الآخر يأخذ اسم ورقة العمل المصدر.

المثال التالي يظهر كيفية نسخ ورقة عمل موجودة داخل سجل العمل.

from aspose.cells import 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(".")
InputPath = dataDir + "book1.xls"
# Open an existing Excel file.
wb = Workbook(InputPath)
# Create a Worksheets object with reference to
# the sheets of the Workbook.
sheets = wb.worksheets
# Copy data to a new sheet from an existing
# sheet within the Workbook.
sheets.add_copy("Sheet1")
# Save the Excel file.
wb.save(dataDir + "CopyWithinWorkbook_out.xls")

كيفية نسخ أوراق العمل بين المصنفات

يوفر Aspose.Cells للبايثون via .NET طريقة، Aspose.Cells.Worksheet.copy() تستخدم لنسخ البيانات والتنسيق من ورقة عمل مصدر إلى ورقة عمل أخرى داخل المصنف أو بين المصنفات. تأخذ الطريقة كائن ورقة العمل المصدر كمعلمة.

يظهر المثال التالي كيفية نسخ ورقة عمل من دفتر عمل إلى دفتر عمل آخر.

from aspose.cells import 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(".")
InputPath = dataDir + "book1.xls"
# Create a Workbook.
# Open a file into the first book.
excelWorkbook0 = Workbook(InputPath)
# Create another Workbook.
excelWorkbook1 = Workbook()
# Copy the first sheet of the first book into second book.
excelWorkbook1.worksheets[0].copy(excelWorkbook0.worksheets[0])
# Save the file.
excelWorkbook1.save(dataDir + "CopyWorksheetsBetweenWorkbooks_out.xls")

المثال التالي يوضح كيفية نسخ ورقة عمل من مصنف إلى مصنف آخر.

from aspose.cells import 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 a new Workbook.
excelWorkbook0 = Workbook()
# Get the first worksheet in the book.
ws0 = excelWorkbook0.worksheets[0]
# Put some data into header rows (A1:A4)
for i in range(5):
headerRow = "Header Row " + str(i)
ws0.cells.get(i, 0).put_value(headerRow)
# Put some detail data (A5:A999)
for i in range(5, 1000):
detailRow = "Detail Row " + str(i)
ws0.cells.get(i, 0).put_value(detailRow)
# Define a pagesetup object based on the first worksheet.
pagesetup = ws0.page_setup
# The first five rows are repeated in each page...
# It can be seen in print preview.
pagesetup.print_title_rows = "$1:$5"
# Create another Workbook.
excelWorkbook1 = Workbook()
# Get the first worksheet in the book.
ws1 = excelWorkbook1.worksheets[0]
# Name the worksheet.
ws1.name = "MySheet"
# Copy data from the first worksheet of the first workbook into the
# first worksheet of the second workbook.
ws1.copy(ws0)
# Save the excel file.
excelWorkbook1.save(dataDir + "CopyWorksheetFromWorkbookToOther_out.xls")

كيفية نقل أوراق العمل ضمن مصنف

يوفر Aspose.Cells للبايثون via .NET طريقة Aspose.Cells.Worksheet.move_to() التي تستخدم لنقل ورقة العمل إلى موقع آخر في نفس الجدول. تأخذ الطريقة مؤشر ورقة العمل الهدف كمعلمة.

المثال التالي يظهر كيفية نقل ورقة عمل إلى موقع آخر داخل سجل العمل.

from aspose.cells import 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(".")
InputPath = dataDir + "book1.xls"
# Open an existing excel file.
wb = Workbook(InputPath)
# Create a Worksheets object with reference to
# the sheets of the Workbook.
sheets = wb.worksheets
# Get the first worksheet.
worksheet = sheets[0]
# Move the first sheet to the third position in the workbook.
worksheet.move_to(2)
# Save the excel file.
wb.save(dataDir + "MoveWorksheet_out.xls")