Çalışma Kitabı veya Çalışma Sayfası yüklenirken Nesneleri Filtrele
Olası Kullanım Senaryoları
Lütfen kullanLoadOptions.LoadFilter çalışma kitabından verileri filtrelerken özelliği. Ancak verileri tek tek çalışma sayfalarından filtrelemek istiyorsanız, geçersiz kılmanız gerekir.LoadFilter.startSheet yöntem. Lütfen uygun değeri girinLoadDataFilterOptions oluştururken veya birlikte çalışırken numaralandırmaYük Filtresi.
buLoadDataFilterOptionsnumaralandırma aşağıdaki değerlere sahiptir.
- YOK
- HERŞEY
- HÜCRE_BLANK
- CELL_STRING
- CELL_NUMERIC
- HÜCRE_HATA
- CELL_BOOL
- HÜCRE_DEĞERİ
- FORMÜL
- HÜCRE_VERİLERİ
- ÇİZELGE
- ŞEKİL
- MERGED_AREA
- KOŞULLU BİÇİMLENDİRME
- VERİ DOĞRULAMA
- PİVOT TABLO
- MASA
- KÖPRÜLER
- SHEET_SETTINGS
- SHEET_DATA
- KİTAP_AYARLARI
- AYARLAR
- XML_MAP
- YAPI
- DÖKÜMAN ÖZELLİKLERİ
- DEFINED_NAMES
- VBA
- STİL
Çalışma Kitabını Yüklerken Nesneleri Filtrele
Aşağıdaki örnek kod, çalışma kitabından grafiklerin nasıl filtreleneceğini gösterir. lütfen kontrol edinizörnek excel dosyası Bu kodda kullanılan veçıkış PDFonun tarafından oluşturulur. PDF çıktısında görebileceğiniz gibi, tüm grafikler çalışma kitabından filtrelendi.
// 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.getSharedDataDir(FilterObjectsLoadingWorkbook.class) + "articles/"; | |
//Filter charts from entire workbook | |
LoadOptions ldOpts = new LoadOptions(); | |
ldOpts.setLoadFilter(new LoadFilter(LoadDataFilterOptions.ALL & ~LoadDataFilterOptions.CHART)); | |
//Load the workbook with above filter | |
Workbook wb = new Workbook(dataDir + "sampleFilterCharts.xlsx", ldOpts); | |
//Save entire worksheet into a single page | |
PdfSaveOptions opts = new PdfSaveOptions(); | |
opts.setOnePagePerSheet(true); | |
//Save the workbook in pdf format with the above pdf save options | |
wb.save(dataDir + "sampleFilterCharts.pdf", opts); |
Çalışma Sayfasını Yüklerken Nesneleri Filtrele
Aşağıdaki örnek kod,kaynak excel dosyası ve özel bir filtre kullanarak aşağıdaki verileri çalışma sayfalarından filtreler.
- NoCharts adlı çalışma sayfasındaki Grafikleri filtreler.
- NoShapes adlı çalışma sayfasındaki Şekilleri filtreler.
- NoConditionalFormatting adlı çalışma sayfasından Koşullu Biçimlendirmeyi filtreler.
Bir kez, yüklerkaynak excel dosyası özel bir filtre ile tüm çalışma sayfalarının resimlerini tek tek alır. İşte referansınız için çıktı görüntüleri. Gördüğünüz gibi, ilk resimde grafikler yok, ikinci resimde şekiller yok ve üçüncü resimde koşullu biçimlendirme yok.
// For complete examples and data files, please go to https://github.com/aspose-cells/Aspose.Cells-for-Java | |
public class FilterObjectsLoadingWorksheets { | |
// Implement your own custom load filter, it will enable you to filter your | |
// individual worksheet | |
class CustomLoadFilter extends LoadFilter { | |
public void startSheet(Worksheet sheet) { | |
if (sheet.getName().equals("NoCharts")) { | |
// Load everything and filter charts | |
this.setLoadDataFilterOptions(LoadDataFilterOptions.ALL& ~LoadDataFilterOptions.CHART); | |
} | |
if (sheet.getName().equals("NoShapes")) { | |
// Load everything and filter shapes | |
this.setLoadDataFilterOptions(LoadDataFilterOptions.ALL& ~LoadDataFilterOptions.DRAWING); | |
} | |
if (sheet.getName().equals("NoConditionalFormatting")) { | |
// Load everything and filter conditional formatting | |
this.setLoadDataFilterOptions(LoadDataFilterOptions.ALL& ~LoadDataFilterOptions.CONDITIONAL_FORMATTING); | |
} | |
}// End StartSheet method. | |
}// End CustomLoadFilter class. | |
public static void main(String[] args) throws Exception { | |
FilterObjectsLoadingWorksheets pg = new FilterObjectsLoadingWorksheets(); | |
pg.Run(); | |
} | |
public void Run() throws Exception { | |
// The path to the documents directory. | |
String dataDir = Utils.getSharedDataDir(FilterObjectsLoadingWorksheets.class) + "TechnicalArticles/"; | |
// Filter worksheets using custom load filter | |
LoadOptions ldOpts = new LoadOptions(); | |
ldOpts.setLoadFilter(new CustomLoadFilter()); | |
// Load the workbook with above filter | |
Workbook wb = new Workbook(dataDir + "sampleFilterDifferentObjects.xlsx", ldOpts); | |
// Take the image of all worksheets one by one | |
for (int i = 0; i < wb.getWorksheets().getCount(); i++) { | |
// Access worksheet at index i | |
Worksheet ws = wb.getWorksheets().get(i); | |
// Create image or print options, we want the image of entire | |
// worksheet | |
ImageOrPrintOptions opts = new ImageOrPrintOptions(); | |
opts.setOnePagePerSheet(true); | |
opts.setImageType(ImageType.PNG); | |
// Convert worksheet into image | |
SheetRender sr = new SheetRender(ws, opts); | |
sr.toImage(0, dataDir + ws.getName() + ".png"); | |
} | |
} | |
} |