コード例 #1
0
 /**
  * POI AutoFilter.getFilterColumn(i) sometimes returns null. A POI FilterColumn object only exists
  * when we have set a criteria on that column. For example, if we enable auto filter on 2 columns,
  * but we only set criteria on 2nd column. Thus, the size of filter column is 1. There is only one
  * FilterColumn object and its column id is 1. Only getFilterColumn(1) will return a FilterColumn,
  * other get null.
  *
  * @param poiSheet source POI sheet
  * @param sheet destination sheet
  */
 protected void importAutoFilter(Sheet poiSheet, SSheet sheet) {
   AutoFilter poiAutoFilter = poiSheet.getAutoFilter();
   if (poiAutoFilter != null) {
     CellRangeAddress filteringRange = poiAutoFilter.getRangeAddress();
     SAutoFilter autoFilter =
         sheet.createAutoFilter(new CellRegion(filteringRange.formatAsString()));
     int numberOfColumn = filteringRange.getLastColumn() - filteringRange.getFirstColumn() + 1;
     importAutoFilterColumns(poiAutoFilter, autoFilter, numberOfColumn); // ZSS-1019
   }
 }
コード例 #2
0
 // ZSS-1019
 protected void importAutoFilterColumns(
     AutoFilter poiFilter, SAutoFilter zssFilter, int numberOfColumn) {
   for (int i = 0; i < numberOfColumn; i++) {
     FilterColumn srcColumn = poiFilter.getFilterColumn(i);
     if (srcColumn == null) {
       continue;
     }
     NFilterColumn destColumn = zssFilter.getFilterColumn(i, true);
     destColumn.setProperties(
         PoiEnumConversion.toFilterOperator(srcColumn.getOperator()),
         srcColumn.getCriteria1(),
         srcColumn.getCriteria2(),
         srcColumn.isOn());
   }
 }