Package org.apache.poi

Examples of org.apache.poi.POIDataSamples


                    cp.getValue();
                }
            }
        };

        POIDataSamples _samples = POIDataSamples.getHPSFInstance();
        final File dataDir = _samples.getFile("");
        final File[] docs = dataDir.listFiles(new FileFilter()
        {
            @Override
            public boolean accept(final File file)
            {
View Full Code Here


   }
   @Override
   protected void setUp() throws Exception {
      super.setUp();

      POIDataSamples ssTests = POIDataSamples.getSpreadSheetInstance();
      xls = getFileAndCheck(ssTests, "SampleSS.xls");
      xlsx = getFileAndCheck(ssTests, "SampleSS.xlsx");
      xltx = getFileAndCheck(ssTests, "test.xltx");
      xlsEmb = getFileAndCheck(ssTests, "excel_with_embeded.xls");

      POIDataSamples wpTests = POIDataSamples.getDocumentInstance();
      doc = getFileAndCheck(wpTests, "SampleDoc.doc");
      doc6 = getFileAndCheck(wpTests, "Word6.doc");
      doc95 = getFileAndCheck(wpTests, "Word95.doc");
      docx = getFileAndCheck(wpTests, "SampleDoc.docx");
      dotx = getFileAndCheck(wpTests, "test.dotx");
      docEmb = getFileAndCheck(wpTests, "word_with_embeded.doc");
      docEmbOOXML = getFileAndCheck(wpTests, "word_with_embeded_ooxml.doc");

      POIDataSamples slTests = POIDataSamples.getSlideShowInstance();
      ppt = getFileAndCheck(slTests, "SampleShow.ppt");
      pptx = getFileAndCheck(slTests, "SampleShow.pptx");
      txt = getFileAndCheck(slTests, "SampleShow.txt");

      POIDataSamples dgTests = POIDataSamples.getDiagramInstance();
      vsd = getFileAndCheck(dgTests, "Test_Visio-Some_Random_Text.vsd");
     
      POIDataSamples pubTests = POIDataSamples.getPublisherInstance();
      pub = getFileAndCheck(pubTests, "Simple.pub");
     
      POIDataSamples olTests = POIDataSamples.getHSMFInstance();
      msg = getFileAndCheck(olTests, "quick.msg");
      msgEmb = getFileAndCheck(olTests, "attachment_test_msg.msg");
      msgEmbMsg = getFileAndCheck(olTests, "attachment_msg_pdf.msg");
   }
View Full Code Here

        assertNotNull(XSSFTestDataSamples.writeOutAndReadBack(w));
    }

    private List<String> readStrings(String filename) throws IOException {
        List<String> strs = new ArrayList<String>();
        POIDataSamples samples = POIDataSamples.getSpreadSheetInstance();
        BufferedReader br = new BufferedReader(
                new InputStreamReader(samples.openResourceAsStream(filename)));
        String s;
        while ((s = br.readLine()) != null) {
            if (s.trim().length() > 0) {
                strs.add(s.trim());
            }
View Full Code Here

     *
     * @exception FileNotFoundException if the file to be read does not exist.
     * @exception IOException if any other I/O exception occurs
     */
    protected void setUp() {
        POIDataSamples samples = POIDataSamples.getHPSFInstance();
        data = samples.getFile(POI_FS);
    }
View Full Code Here

   /**
    * Initialize this test, load up the messages.
    */
   public TestFixedSizedProperties() throws Exception {
       POIDataSamples samples = POIDataSamples.getHSMFInstance();
      this.mapiMessageSucceeds = new MAPIMessage(
                samples.openResourceAsStream(messageSucceeds));
      this.mapiMessageFails = new MAPIMessage(
                samples.openResourceAsStream(messageFails));   
      this.fsMessageSucceeds = new POIFSFileSystem(new FileInputStream(samples.getFile(messageSucceeds)));
      this.fsMessageFails = new POIFSFileSystem(new FileInputStream(samples.getFile(messageFails)));
     
      messageDateFormat = new SimpleDateFormat("E, d MMM yyyy HH:mm:ss");
      messageDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
   }
View Full Code Here

    public void testReadDocumentSummaryInformation()
            throws FileNotFoundException, IOException,
            NoPropertySetStreamException, MarkUnsupportedException,
            UnexpectedPropertySetTypeException
    {
        POIDataSamples _samples = POIDataSamples.getHPSFInstance();
        final File dataDir = _samples.getFile("");
        final File[] docs = dataDir.listFiles(new FileFilter()
        {
            public boolean accept(final File file)
            {
                return file.isFile() && file.getName().startsWith("Test");
View Full Code Here

     */
    public void testWriteWellKnown() throws IOException,
            NoPropertySetStreamException, MarkUnsupportedException,
            UnexpectedPropertySetTypeException, WritingNotSupportedException
    {
        POIDataSamples _samples = POIDataSamples.getHPSFInstance();
        final File dataDir = _samples.getFile("");
        final File doc1 = new File(dataDir, POI_FS);

        /* Read a test document <em>doc1</em> into a POI filesystem. */
        POIFSFileSystem poifs = new POIFSFileSystem(new FileInputStream(doc1));
        DirectoryEntry dir = poifs.getRoot();
View Full Code Here

                    cp.getValue();
                }
            }
        };

        POIDataSamples _samples = POIDataSamples.getHPSFInstance();
        final File dataDir = _samples.getFile("");
        final File[] docs = dataDir.listFiles(new FileFilter()
        {
            public boolean accept(final File file)
            {
                return file.isFile() && file.getName().startsWith("Test");
View Full Code Here

  /**
   * Excel embeded in excel
   */
  public void testWithEmbededInOwn() throws Exception {
    POIDataSamples ssSamples = POIDataSamples.getSpreadSheetInstance();
    POIFSFileSystem fs = new POIFSFileSystem(
        ssSamples.openResourceAsStream("excel_with_embeded.xls")
    );

    DirectoryNode dirA = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B5");
    DirectoryNode dirB = (DirectoryNode) fs.getRoot().getEntry("MBD0000A3B4");

View Full Code Here

*
* @author Yegor Kozlov
*/
public final class TestSound extends TestCase {
  public void testRealFile() throws Exception {
        POIDataSamples slTests = POIDataSamples.getSlideShowInstance();

    SlideShow ppt = new SlideShow(slTests.openResourceAsStream("sound.ppt"));

    // Get the document
    Document doc = ppt.getDocumentRecord();
    SoundCollection soundCollection = null;
    Record[] doc_ch = doc.getChildRecords();
    for (int i = 0; i < doc_ch.length; i++) {
      if (doc_ch[i] instanceof SoundCollection) {
        soundCollection = (SoundCollection) doc_ch[i];
        break;
      }
    }
    if (soundCollection == null) {
      throw new AssertionFailedError("soundCollection must not be null");
    }

    Sound sound = null;
    Record[] sound_ch = soundCollection.getChildRecords();
    int k = 0;
    for (int i = 0; i < sound_ch.length; i++) {
      if (sound_ch[i] instanceof Sound) {
        sound = (Sound) sound_ch[i];
        k++;
      }
    }
    if (sound == null) {
      throw new AssertionFailedError("sound must not be null");
    }
    assertEquals(1, k);

    assertEquals("ringin.wav", sound.getSoundName());
    assertEquals(".WAV", sound.getSoundType());
    assertNotNull(sound.getSoundData());

    byte[] ref_data = slTests.readFile("ringin.wav");
    assertArrayEquals(ref_data, sound.getSoundData());
  }
View Full Code Here

TOP

Related Classes of org.apache.poi.POIDataSamples

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.