从jxl excelparsing器转换为Apache Poi?

我必须从jxlparsing器的逻辑转换到Apache poi

我想要安全的现有逻辑。

这里是jxl片段:

 public class Ancillaries { private Workbook workbook; private EntryParser shortParser; private EntryParser longParser; private Sheet sheet; private Cell lowShortStart; private Cell lowShortEnd; private Cell highShortStart; private Cell highShortEnd; private Cell lowLongStart; private Cell lowLongEnd; private Cell highLongStart; private Cell highLongEnd; public Ancillaries(File xls, String sheetName) { try { workbook = Workbook.getWorkbook(xls); sheet = workbook.getSheet(sheetName); shortParser = new EntryParser(); longParser = new EntryParser(); } catch (Exception e) { throw new RuntimeException("can not find xls file", e); } } public Ancillaries(String xls, String sheetName) { this(new File(xls), sheetName); } public List<BagPricing> parse() { List<BagPricing> bags = new ArrayList<BagPricing>(); List<BagPricing> lowSeasonBagsS = shortParser.getTable(lowShortStart, lowShortEnd, Haul.SHORT_HAUL, Season.LOW); List<BagPricing> highSeasonBagsS = shortParser.getTable(highShortStart, highShortEnd, Haul.SHORT_HAUL, Season.HIGH); List<BagPricing> lowSeasonBagsL = longParser.getTable(lowLongStart, lowLongEnd, Haul.LONG_HAUL, Season.LOW); List<BagPricing> highSeasonBagsL = longParser.getTable(highLongStart, highLongEnd, Haul.LONG_HAUL, Season.HIGH); bags.addAll(lowSeasonBagsS); bags.addAll(highSeasonBagsS); bags.addAll(lowSeasonBagsL); bags.addAll(highSeasonBagsL); return bags; } public void setDefault() { setRowKey("C30", "AR30"); setLowSeasonShort("D30", "U40"); setHighSeasonShort("W30", "AN40"); setLowSeasonLong("AR30", "BI42"); setHighSeasonLong("BK30", "CC42"); } public void setRowKey(String shortCell, String longSell) { shortParser.rowKey = sheet.getCell(shortCell).getColumn(); longParser.rowKey = sheet.getCell(longSell).getColumn(); } public void setLowSeasonShort(String startCell, String endCell) { this.lowShortStart = sheet.getCell(startCell); this.lowShortEnd = sheet.getCell(endCell); } public void setHighSeasonShort(String startCell, String endCell) { this.highShortStart = sheet.getCell(startCell); this.highShortEnd = sheet.getCell(endCell); } public void setLowSeasonLong(String startCell, String endCell) { this.lowLongStart = sheet.getCell(startCell); this.lowLongEnd = sheet.getCell(endCell); } public void setHighSeasonLong(String startCell, String endCell) { this.highLongStart = sheet.getCell(startCell); this.highLongEnd = sheet.getCell(endCell); } 

我想知道如何从setDefault()更改逻辑到使用Apache Poi 。 我试图在poi API上find类似的东西。 但不要成见。

有什么build议么?