PageRenderTime 54ms CodeModel.GetById 16ms RepoModel.GetById 1ms app.codeStats 0ms

/src/main/java/uk/ac/manchester/cs/owl/semspreadsheets/model/hssf/impl/NamedRangeHSSFImpl.java

https://github.com/semantalytics/RightField
Java | 45 lines | 25 code | 8 blank | 12 comment | 0 complexity | 6d7896824d188b80c277a454ec717d48 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. /*******************************************************************************
  2. * Copyright (c) 2009-2012, University of Manchester
  3. *
  4. * Licensed under the New BSD License.
  5. * Please see LICENSE file that is distributed with the source code
  6. ******************************************************************************/
  7. package uk.ac.manchester.cs.owl.semspreadsheets.model.hssf.impl;
  8. import org.apache.poi.hssf.usermodel.HSSFName;
  9. import org.apache.poi.hssf.util.AreaReference;
  10. import org.apache.poi.ss.util.CellReference;
  11. import uk.ac.manchester.cs.owl.semspreadsheets.model.NamedRange;
  12. import uk.ac.manchester.cs.owl.semspreadsheets.model.Range;
  13. /**
  14. * Author: Matthew Horridge<br>
  15. * The University of Manchester<br>
  16. * Information Management Group<br>
  17. * Date: 08-Nov-2009
  18. */
  19. public class NamedRangeHSSFImpl implements NamedRange {
  20. private WorkbookHSSFImpl workbook;
  21. private HSSFName name;
  22. public NamedRangeHSSFImpl(WorkbookHSSFImpl workbook, HSSFName name) {
  23. this.workbook = workbook;
  24. this.name = name;
  25. }
  26. public String getName() {
  27. return name.getNameName();
  28. }
  29. public Range getRange() {
  30. String sheetName = name.getSheetName();
  31. String formula = name.getRefersToFormula();
  32. AreaReference areaReference = new AreaReference(formula);
  33. CellReference firstCellReference = areaReference.getFirstCell();
  34. CellReference lastCellReference = areaReference.getLastCell();
  35. return new Range(workbook.getSheet(sheetName), firstCellReference.getCol(), firstCellReference.getRow(), lastCellReference.getCol(), lastCellReference.getRow());
  36. }
  37. }