تحميل الأوراق العمل المحددة في كتيب عمل
Contents
[
Hide
]
بشكل افتراضي، تقوم Aspose.Cells بتحميل جدول البيانات بالكامل إلى الذاكرة. من الممكن تحميل ورق العمل محددة فقط. يمكن أن يحسن هذا الأداء ويستهلك أقل كمية من الذاكرة. يكون هذا النهج مفيدًا عند العمل مع كتيب عمل كبير يحتوي على عدة أوراق عمل.
تحميل الأوراق العمل المحددة في كتيب عمل
This file contains hidden or 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(LoadSpecificWorksheetsinWorkbook.class); | |
//Define a new Workbook | |
Workbook workbook; | |
/// Load the workbook with the specified worksheet only. | |
LoadOptions loadOptions = new LoadOptions(LoadFormat.XLSX); | |
loadOptions.setLoadFilter(new CustomLoad()); | |
// Creat the workbook. | |
workbook = new Workbook(dataDir+ "TestData.xlsx", loadOptions); | |
// Perform your desired task. | |
// Save the workbook. | |
workbook.save(dataDir+ "outputFile.out.xlsx"); | |
public class CustomLoad extends LoadFilter | |
{ | |
public void startSheet(Worksheet sheet) | |
{ | |
if (sheet.getName() == "Sheet2") | |
{ | |
// Load everything from worksheet "Sheet2" | |
this.setLoadDataFilterOptions(LoadDataFilterOptions.ALL); | |
} | |
else | |
{ | |
// Load nothing | |
this.setLoadDataFilterOptions(LoadDataFilterOptions.NONE); | |
} | |
} | |
} |