Du kannst nicht mehr als 25 Themen auswählen Themen müssen mit entweder einem Buchstaben oder einer Ziffer beginnen. Sie können Bindestriche („-“) enthalten und bis zu 35 Zeichen lang sein.

TestEFBiffViewer.java 3.5KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  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.dev;
  16. import java.io.File;
  17. import java.io.IOException;
  18. import java.io.PrintStream;
  19. import org.apache.poi.EncryptedDocumentException;
  20. import org.apache.poi.hssf.OldExcelFormatException;
  21. import org.apache.poi.hssf.record.RecordInputStream;
  22. import org.apache.poi.util.LocaleUtil;
  23. import org.apache.poi.util.RecordFormatException;
  24. import org.junit.BeforeClass;
  25. public class TestEFBiffViewer extends BaseXLSIteratingTest {
  26. @BeforeClass
  27. public static void setup() {
  28. EXCLUDED.clear();
  29. EXCLUDED.put("35897-type4.xls", EncryptedDocumentException.class); // unsupported crypto api header
  30. EXCLUDED.put("51832.xls", EncryptedDocumentException.class);
  31. EXCLUDED.put("xor-encryption-abc.xls", EncryptedDocumentException.class);
  32. EXCLUDED.put("password.xls", EncryptedDocumentException.class);
  33. EXCLUDED.put("46904.xls", OldExcelFormatException.class);
  34. EXCLUDED.put("59074.xls", OldExcelFormatException.class);
  35. EXCLUDED.put("testEXCEL_2.xls", OldExcelFormatException.class); // Biff 2 / Excel 2, pre-OLE2
  36. EXCLUDED.put("testEXCEL_3.xls", OldExcelFormatException.class); // Biff 3 / Excel 3, pre-OLE2
  37. EXCLUDED.put("testEXCEL_4.xls", OldExcelFormatException.class); // Biff 4 / Excel 4, pre-OLE2
  38. EXCLUDED.put("testEXCEL_5.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
  39. EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 5
  40. EXCLUDED.put("testEXCEL_95.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
  41. EXCLUDED.put("60284.xls", OldExcelFormatException.class); // Biff 5 / Excel 95
  42. EXCLUDED.put("43493.xls", RecordInputStream.LeftoverDataException.class); // HSSFWorkbook cannot open it as well
  43. EXCLUDED.put("44958_1.xls", RecordInputStream.LeftoverDataException.class);
  44. EXCLUDED.put("XRefCalc.xls", RuntimeException.class); // "Buffer overrun"
  45. EXCLUDED.put("61300.xls", RecordFormatException.class);
  46. }
  47. @Override
  48. void runOneFile(File fileIn) throws IOException {
  49. PrintStream save = System.out;
  50. try {
  51. // redirect standard out during the test to avoid spamming the console with output
  52. System.setOut(new PrintStream(NULL_OUTPUT_STREAM,true,LocaleUtil.CHARSET_1252.name()));
  53. EFBiffViewer.main(new String[] { fileIn.getAbsolutePath() });
  54. } finally {
  55. System.setOut(save);
  56. }
  57. }
  58. //@Test
  59. public void testFile() throws IOException {
  60. EFBiffViewer viewer = new EFBiffViewer();
  61. viewer.setFile(new File("test-data/spreadsheet/59074.xls").getAbsolutePath());
  62. viewer.run();
  63. }
  64. }