You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

EvaluationWorkbook.java 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /* ====================================================================
  2. Licensed to the Apache Software Foundation (ASF) under one or more
  3. contributor license agreements. See the NOTICE file distributed with
  4. this work for additional information regarding copyright ownership.
  5. The ASF licenses this file to You under the Apache License, Version 2.0
  6. (the "License"); you may not use this file except in compliance with
  7. the License. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. ==================================================================== */
  15. package org.apache.poi.ss.formula;
  16. import org.apache.poi.ss.formula.ptg.NamePtg;
  17. import org.apache.poi.ss.formula.ptg.NameXPtg;
  18. import org.apache.poi.ss.formula.ptg.Ptg;
  19. import org.apache.poi.ss.formula.udf.UDFFinder;
  20. /**
  21. * Abstracts a workbook for the purpose of formula evaluation.<br/>
  22. *
  23. * For POI internal use only
  24. *
  25. * @author Josh Micich
  26. */
  27. public interface EvaluationWorkbook {
  28. String getSheetName(int sheetIndex);
  29. /**
  30. * @return -1 if the specified sheet is from a different book
  31. */
  32. int getSheetIndex(EvaluationSheet sheet);
  33. /**
  34. * Finds a sheet index by case insensitive name.
  35. * @return the index of the sheet matching the specified name. -1 if not found
  36. */
  37. int getSheetIndex(String sheetName);
  38. EvaluationSheet getSheet(int sheetIndex);
  39. /**
  40. * @return <code>null</code> if externSheetIndex refers to a sheet inside the current workbook
  41. */
  42. ExternalSheet getExternalSheet(int externSheetIndex);
  43. int convertFromExternSheetIndex(int externSheetIndex);
  44. ExternalName getExternalName(int externSheetIndex, int externNameIndex);
  45. EvaluationName getName(NamePtg namePtg);
  46. EvaluationName getName(String name, int sheetIndex);
  47. String resolveNameXText(NameXPtg ptg);
  48. Ptg[] getFormulaTokens(EvaluationCell cell);
  49. UDFFinder getUDFFinder();
  50. class ExternalSheet {
  51. private final String _workbookName;
  52. private final String _sheetName;
  53. public ExternalSheet(String workbookName, String sheetName) {
  54. _workbookName = workbookName;
  55. _sheetName = sheetName;
  56. }
  57. public String getWorkbookName() {
  58. return _workbookName;
  59. }
  60. public String getSheetName() {
  61. return _sheetName;
  62. }
  63. }
  64. class ExternalName {
  65. private final String _nameName;
  66. private final int _nameNumber;
  67. private final int _ix;
  68. public ExternalName(String nameName, int nameNumber, int ix) {
  69. _nameName = nameName;
  70. _nameNumber = nameNumber;
  71. _ix = ix;
  72. }
  73. public String getName() {
  74. return _nameName;
  75. }
  76. public int getNumber() {
  77. return _nameNumber;
  78. }
  79. public int getIx() {
  80. return _ix;
  81. }
  82. }
  83. }