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.

HSSFWorkbookFactory.java 2.4KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 java.io.IOException;
  17. import org.apache.poi.poifs.filesystem.DirectoryNode;
  18. import org.apache.poi.poifs.filesystem.POIFSFileSystem;
  19. import org.apache.poi.ss.usermodel.WorkbookFactory;
  20. import org.apache.poi.util.Internal;
  21. /**
  22. * Helper class which is instantiated by reflection from
  23. * {@link WorkbookFactory#create(java.io.File)} and similar
  24. */
  25. @SuppressWarnings("unused")
  26. @Internal
  27. public class HSSFWorkbookFactory extends WorkbookFactory {
  28. static {
  29. WorkbookFactory.createHssfFromScratch = HSSFWorkbookFactory::createWorkbook;
  30. WorkbookFactory.createHssfByNode = HSSFWorkbookFactory::createWorkbook;
  31. }
  32. /**
  33. * Create a new empty Workbook
  34. *
  35. * @return The created workbook
  36. */
  37. public static HSSFWorkbook createWorkbook() {
  38. return new HSSFWorkbook();
  39. }
  40. /**
  41. * Creates a HSSFWorkbook from the given {@link POIFSFileSystem}<p>
  42. * Note that in order to properly release resources the
  43. * Workbook should be closed after use.
  44. */
  45. public static HSSFWorkbook createWorkbook(final POIFSFileSystem fs) throws IOException {
  46. return new HSSFWorkbook(fs);
  47. }
  48. /**
  49. * Creates a HSSFWorkbook from the given DirectoryNode<p>
  50. * Note that in order to properly release resources the
  51. * Workbook should be closed after use.
  52. */
  53. public static HSSFWorkbook createWorkbook(final DirectoryNode root) throws IOException {
  54. return new HSSFWorkbook(root, true);
  55. }
  56. }