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.8KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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.hssf.record.formula.NamePtg;
  17. import org.apache.poi.hssf.record.formula.NameXPtg;
  18. import org.apache.poi.hssf.record.formula.Ptg;
  19. import org.apache.poi.hssf.record.formula.functions.FreeRefFunction;
  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. * Modified 09/07/09 by Petr Udalau - added methods for searching for UDFs of this Workbook.
  28. */
  29. public interface EvaluationWorkbook {
  30. String getSheetName(int sheetIndex);
  31. /**
  32. * @return -1 if the specified sheet is from a different book
  33. */
  34. int getSheetIndex(EvaluationSheet sheet);
  35. /**
  36. * Finds a sheet index by case insensitive name.
  37. * @return the index of the sheet matching the specified name. -1 if not found
  38. */
  39. int getSheetIndex(String sheetName);
  40. EvaluationSheet getSheet(int sheetIndex);
  41. /**
  42. * @return <code>null</code> if externSheetIndex refers to a sheet inside the current workbook
  43. */
  44. ExternalSheet getExternalSheet(int externSheetIndex);
  45. int convertFromExternSheetIndex(int externSheetIndex);
  46. EvaluationName getName(NamePtg namePtg);
  47. String resolveNameXText(NameXPtg ptg);
  48. Ptg[] getFormulaTokens(EvaluationCell cell);
  49. /**
  50. * Find and return user defined function (UDF) contained by workbook with
  51. * specified name.
  52. *
  53. * @param functionName UDF name
  54. * @return instance of FreeRefFunction or null if no UDF with the specified
  55. * name exists.
  56. */
  57. FreeRefFunction findUserDefinedFunction(String functionName);
  58. class ExternalSheet {
  59. private final String _workbookName;
  60. private final String _sheetName;
  61. public ExternalSheet(String workbookName, String sheetName) {
  62. _workbookName = workbookName;
  63. _sheetName = sheetName;
  64. }
  65. public String getWorkbookName() {
  66. return _workbookName;
  67. }
  68. public String getSheetName() {
  69. return _sheetName;
  70. }
  71. }
  72. }