Dosyaları Birleştirme

Giriş

Aspose.Cells for Python via .NET farklı dosya birleştirme yolları sağlar. Veri, biçimlendirme ve formülleri olan basit dosyalar için, Workbook.combine() yöntemi birkaç çalışma kitabını birleştirmek için kullanılabilir, ve Worksheet.copy() yöntemi çalışma sayfalarını yeni bir çalışma kitabına kopyalamak için kullanılabilir. Bu yöntemler kullanımı kolay ve etkilidir, fakat çok sayıda dosyayı birleştiriyorsanız, sistem kaynaklarını çok kullanabilirler. Bunu önlemek için, daha verimli bir yol olan CellsHelper.merge_files statik yöntemini kullanın, birkaç dosyayı birleştirirken daha etkilidir.

Aspose.Cells for Python via .NET kullanarak Dosya Birleştirme

Aşağıdaki örnek kod, CellsHelper.merge_files yöntemini kullanarak büyük dosyaları birleştirmenin nasıl yapılacağını göstermektedir. Basit ancak büyük verilere ve formüllere sahip Book1.xls ve Book2.xls adlı iki dosya alır.

from aspose.cells import Workbook, CellsHelper
# For complete examples and data files, please go to https:# github.com/aspose-cells/Aspose.Cells-for-.NET
# Create an Array (length=2)
files = ["Book1.xls", "Book1.xlsx"]
# Create a cachedFile for the process
cacheFile = "test.txt"
# Output File to be created
dest = "output.xlsx";
# # Merge the files in the output file. Supports only .xls files
CellsHelper.merge_files(files, cacheFile, dest);
# Now if you need to rename your sheets, you may load the output file
workbook = Workbook("output.xlsx")
i = 1
# Browse all the sheets to rename them accordingly
for sheet in workbook.worksheets:
sheet.name = "Sheet1" + str(i)
i
i = i + 1
# Re-save the file
workbook.save("output.xlsx")