您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

XSSFCreationHelper.java 3.2KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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.xssf.usermodel;
  16. import org.apache.poi.common.usermodel.HyperlinkType;
  17. import org.apache.poi.ss.usermodel.CreationHelper;
  18. import org.apache.poi.ss.usermodel.Hyperlink;
  19. import org.apache.poi.util.Internal;
  20. import org.apache.poi.util.Removal;
  21. public class XSSFCreationHelper implements CreationHelper {
  22. private final XSSFWorkbook workbook;
  23. /**
  24. * Should only be called by {@link XSSFWorkbook#getCreationHelper()}
  25. *
  26. * @param wb the workbook to create objects for
  27. */
  28. @Internal
  29. public XSSFCreationHelper(XSSFWorkbook wb) {
  30. workbook = wb;
  31. }
  32. /**
  33. * Creates a new XSSFRichTextString for you.
  34. */
  35. @Override
  36. public XSSFRichTextString createRichTextString(String text) {
  37. XSSFRichTextString rt = new XSSFRichTextString(text);
  38. rt.setStylesTableReference(workbook.getStylesSource());
  39. return rt;
  40. }
  41. @Override
  42. public XSSFDataFormat createDataFormat() {
  43. return workbook.createDataFormat();
  44. }
  45. @Override
  46. public XSSFColor createExtendedColor() {
  47. return new XSSFColor();
  48. }
  49. /**
  50. * Create a new XSSFHyperlink.
  51. *
  52. * @param type - the type of hyperlink to create, see {@link HyperlinkType}
  53. * @deprecated POI 3.15 beta 3. Use {@link #createHyperlink(HyperlinkType)} instead.
  54. */
  55. @Deprecated
  56. @Removal(version="3.17")
  57. @Override
  58. public XSSFHyperlink createHyperlink(int type) {
  59. return new XSSFHyperlink(type);
  60. }
  61. /**
  62. * Create a new XSSFHyperlink.
  63. *
  64. * @param type - the type of hyperlink to create, see {@link Hyperlink}
  65. */
  66. @Override
  67. public XSSFHyperlink createHyperlink(HyperlinkType type) {
  68. return new XSSFHyperlink(type);
  69. }
  70. /**
  71. * Creates a XSSFFormulaEvaluator, the object that evaluates formula cells.
  72. *
  73. * @return a XSSFFormulaEvaluator instance
  74. */
  75. @Override
  76. public XSSFFormulaEvaluator createFormulaEvaluator() {
  77. return new XSSFFormulaEvaluator(workbook);
  78. }
  79. /**
  80. * Creates a XSSFClientAnchor. Use this object to position drawing object in
  81. * a sheet
  82. *
  83. * @return a XSSFClientAnchor instance
  84. * @see org.apache.poi.ss.usermodel.Drawing
  85. */
  86. @Override
  87. public XSSFClientAnchor createClientAnchor() {
  88. return new XSSFClientAnchor();
  89. }
  90. }