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.

HSSFCreationHelper.java 3.1KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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.hssf.usermodel;
  16. import org.apache.poi.common.usermodel.HyperlinkType;
  17. import org.apache.poi.hssf.record.common.ExtendedColor;
  18. import org.apache.poi.ss.usermodel.CreationHelper;
  19. import org.apache.poi.ss.util.AreaReference;
  20. import org.apache.poi.ss.util.CellReference;
  21. import org.apache.poi.util.Internal;
  22. public class HSSFCreationHelper implements CreationHelper {
  23. private final HSSFWorkbook workbook;
  24. /**
  25. * Should only be called by {@link HSSFWorkbook#getCreationHelper()}
  26. *
  27. * @param wb the workbook to create objects for
  28. */
  29. @Internal(since="3.15 beta 3")
  30. /*package*/ HSSFCreationHelper(HSSFWorkbook wb) {
  31. workbook = wb;
  32. }
  33. @Override
  34. public HSSFRichTextString createRichTextString(String text) {
  35. return new HSSFRichTextString(text);
  36. }
  37. @Override
  38. public HSSFDataFormat createDataFormat() {
  39. return workbook.createDataFormat();
  40. }
  41. @Override
  42. public HSSFHyperlink createHyperlink(HyperlinkType type) {
  43. return new HSSFHyperlink(type);
  44. }
  45. @Override
  46. public HSSFExtendedColor createExtendedColor() {
  47. return new HSSFExtendedColor(new ExtendedColor());
  48. }
  49. /**
  50. * Creates a HSSFFormulaEvaluator, the object that evaluates formula cells.
  51. *
  52. * @return a HSSFFormulaEvaluator instance
  53. */
  54. @Override
  55. public HSSFFormulaEvaluator createFormulaEvaluator(){
  56. return new HSSFFormulaEvaluator(workbook);
  57. }
  58. /**
  59. * Creates a HSSFClientAnchor. Use this object to position drawing object in a sheet
  60. *
  61. * @return a HSSFClientAnchor instance
  62. * @see org.apache.poi.ss.usermodel.Drawing
  63. */
  64. @Override
  65. public HSSFClientAnchor createClientAnchor(){
  66. return new HSSFClientAnchor();
  67. }
  68. /**
  69. * {@inheritDoc}
  70. */
  71. @Override
  72. public AreaReference createAreaReference(String reference) {
  73. return new AreaReference(reference, workbook.getSpreadsheetVersion());
  74. }
  75. /**
  76. * {@inheritDoc}
  77. */
  78. @Override
  79. public AreaReference createAreaReference(CellReference topLeft, CellReference bottomRight) {
  80. return new AreaReference(topLeft, bottomRight, workbook.getSpreadsheetVersion());
  81. }
  82. }