PageRenderTime 89ms CodeModel.GetById 29ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/uk/ac/manchester/cs/owl/semspreadsheets/model/xssf/impl/NamedRangeXSSFImpl.java

https://github.com/semantalytics/RightField
Java | 39 lines | 25 code | 8 blank | 6 comment | 0 complexity | 75768c57522bf31c2237a3e2bdf34def MD5 | raw file
Possible License(s): BSD-3-Clause
  1. package uk.ac.manchester.cs.owl.semspreadsheets.model.xssf.impl;
  2. import org.apache.poi.hssf.util.AreaReference;
  3. import org.apache.poi.ss.util.CellReference;
  4. import org.apache.poi.xssf.usermodel.XSSFName;
  5. import uk.ac.manchester.cs.owl.semspreadsheets.model.NamedRange;
  6. import uk.ac.manchester.cs.owl.semspreadsheets.model.Range;
  7. /**
  8. * Author: Matthew Horridge<br>
  9. * The University of Manchester<br>
  10. * Information Management Group<br>
  11. * Date: 08-Nov-2009
  12. */
  13. public class NamedRangeXSSFImpl implements NamedRange {
  14. private WorkbookXSSFImpl workbook;
  15. private XSSFName name;
  16. public NamedRangeXSSFImpl(WorkbookXSSFImpl workbook, XSSFName name) {
  17. this.workbook = workbook;
  18. this.name = name;
  19. }
  20. public String getName() {
  21. return name.getNameName();
  22. }
  23. public Range getRange() {
  24. String sheetName = name.getSheetName();
  25. String formula = name.getRefersToFormula();
  26. AreaReference areaReference = new AreaReference(formula);
  27. CellReference firstCellReference = areaReference.getFirstCell();
  28. CellReference lastCellReference = areaReference.getLastCell();
  29. return new Range(workbook.getSheet(sheetName), firstCellReference.getCol(), firstCellReference.getRow(), lastCellReference.getCol(), lastCellReference.getRow());
  30. }
  31. }