import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;

import org.apache.poi.poifs.filesystem.POIFSFileSystem;

/**
 * TestEventBasedExcelExtractor
 */
public final class TestEventBasedExcelExtractor {

        /**
         * constructor
         */
        public TestEventBasedExcelExtractor(String filename) {

                File file = new File(filename);
                
                FileInputStream fileInputStream = null;
                POIFSFileSystem poiFSFileSystem = null;

                try {
                        fileInputStream = new FileInputStream(file);
                        poiFSFileSystem = new POIFSFileSystem(fileInputStream);
                } 
                catch (FileNotFoundException e) {
                        System.out.println ("TestEventBasedExcelExtractor: 
file: " + 
file.getAbsoluteFile());
                        e.printStackTrace();
                } 
                catch (IOException e) {
                        e.printStackTrace();
                }

                EventBasedExcelExtractor eventBasedExcelExtractor = new
EventBasedExcelExtractor(poiFSFileSystem);
                eventBasedExcelExtractor.setFormulasNotResults(true); // set to 
true to
see formula in cell
                String string = eventBasedExcelExtractor.getText();

                System.out.println ("TestEventBasedExcelExtractor: string:\n" + 
 string);

        // Output string to file
                // Use Apache Commons IO 
//              String filenameNoExtension =  
FilenameUtils.getFullPath(filename) +
FilenameUtils.getBaseName(filename);
//
//              BufferedWriter bufferedWriter = null;
//              try {
//                      bufferedWriter = new BufferedWriter(new 
FileWriter(filenameNoExtension
+ ".txt"));
//                      bufferedWriter.write(string);
//                      bufferedWriter.close();         
//              } 
//              catch (IOException e) {
//                      e.printStackTrace();
//              }

        }

        /**
         *
         * @param args Expect one argument that is the file to read.
         */
        public static void main(String[] args) throws IOException {

                String filename = null;

                if (args.length == 0) {
                        System.out.println ("Please supply filename on command 
line");
                }
                else {
                        filename = args[0];
                }

                TestEventBasedExcelExtractor testEventBasedExcelExtractor = new
TestEventBasedExcelExtractor(filename);

        }
}


--
View this message in context: 
http://apache-poi.1045710.n5.nabble.com/Where-is-POI-formula-read-for-HSSF-tp4967675p4974849.html
Sent from the POI - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to