I have not looked at Yegor's code so I cannot be absolutely certain what you
mean about stdout. Though it may not be wise to do so, I am going to assume
that you mean the System.out.println(...) statement is being used to display
the output of the program. If this is truly the case then were you aware
that you can very easilly redirect System.out so that it outputs to a file
and not to the screen? Take a look at the static System.setOut() method to
see what I mean. The basic idiom is to 'catch' the existing PrintStream
object something like this;

PrintStream currOut = System.out;

Then you can redirect the output to a file something like this;

PrintStream fileOut = new PrintStream(new File("myfile.txt"));
System.setOut(fileOut);

Now when a statement such as the following is executed;

System.out.println("Write this to standard output.");

it will be redirected to the file myfile.txt.

Once you have finished, it is always wise to re-establish the original
PrintStream object so that standard output goes to the screen again,
something like this;

System.setOut(currOut);

If, and that is IF, the program currently outputs it's results using the
System.out..... command, this will allow you to quickly and easilly redirect
output to a file without requiring too many new lines of code.

Yours

Mark B


peterconn wrote:
> 
> Chris,
> Downloaded the Yegor version and it compiled first go.
> But still ran into package errors when attempting to run the class.
> 
> However, along the lines suggested by Bobby, if I compile it using the -d
> option to specify my local directory then the class will get created in a
> directory tree that matches the package statement.
> javac -d /home/pjctest/java  XLSX2CSV.java
> 
> Then I find I can successfully run the class using -
> java org.apache.poi.xssf.eventusermodel.XLSX2CSV TestSheetB.xlsx  
> 
> At least I'm getting a good csv output now.
> I'll just have to figure how to implement this just using jar files, since
> that it my aim.
> I guess it was too much too expect that there might be an option to
> specify a file as the target instead of stdout but I'll take what I can
> get.
> 
> Thanks a bunch,
> 
> Petert 
> 
> 
> 
> 
> 
> 
> ChrisLott wrote:
>> 
>> Did you try the version that Yegor put into the POI source area?  The 
>> early version that I created used two separate classes.  Yegor merged 
>> things together so the single file stands alone.  Here is his version, 
>> where you will see teh ReadonlySharedStringsTable class within the outer 
>> XLSX2CSV class:
>> 
>> http://svn.apache.org/repos/asf/poi/trunk/src/examples/src/org/apache/poi/xssf/eventusermodel/XLSX2CSV.java
>> 
>> If that fails, well, you can try my earlier version, but I really don't 
>> recommend it anymore; if you insist, look at page 
>> http://chris-lott.org/software/ for the xlsx2csv zip file.
>> 
>> HTH
>> 
>> chris...
>> 
>> p.s. A package is a fundamental unit of organization for a Java program. 
>>   Please read up on the basics of Java before asking for help with this 
>> sort of thing.
>> 
>> p.p.s. Java is a P.I.T.A. when working with crude tools like javac.  I 
>> recommend trying Eclipse, the best Java IDE that I have ever used.
>> 
>> peterconn wrote:
>>> Hi,
>>> I copied the XLSX2CSV example using XSSF from this forum but have
>>> trouble
>>> getting a clean compile.
>>> My java skills are limited so I simply compile from the command line
>>> using
>>> javac.
>>> 
>>> I have downloaded the latest POI release from Apache as
>>> poi-bin-3.5-FINAL-20090928.zip and unzipped all the jar files and added
>>> these to my classpath.
>>> 
>>> poi-ooxml-3.5-FINAL-20090928.jar
>>> poi-scratchpad-3.5-FINAL-20090928.jar
>>> poi-contrib-3.5-FINAL-20090928.jar
>>> poi-3.5-FINAL-20090928.jar
>>> commons-logging-1.1.jar
>>> geronimo-stax-api_1.0_spec-1.0.jar
>>> xmlbeans-2.3.0.jar
>>> dom4j-1.6.1.jar
>>> junit-3.8.1.jar
>>> log4j-1.2.13.jar
>>> ooxml-schemas-1.0.jar
>>> 
>>> The compile initially failed to find the ReadonlySharedStringsTable
>>> class so
>>> I downloaded that code from this forum and complied class
>>> ReadonlySharedStringsTable on the first attempt.
>>> Please note that the only change I made was to remove the package
>>> statement.
>>> I simply compiled ReadonlySharedStringsTable into my local directory as
>>> I
>>> normally do with other classes.
>>> 
>>> Before compiling XLSX2CSV I also remove the package statement inserted
>>> by
>>> Chris Lott.
>>> But this compile fails with the error -
>>> 
>>> XLSX2CSV.java:376: cannot find symbol                                       
>>>                                  
>>> symbol  : constructor
>>> ReadonlySharedStringsTable(org.apache.poi.openxml4j.opc.OPCPackage)         
>>>            
>>> location: class ReadonlySharedStringsTable                                  
>>>                                  
>>>                 ReadonlySharedStringsTable strings = new
>>> ReadonlySharedStringsTable(this.xlsxPackage);       
>>> 
>>> 
>>> This package thing has me confused.
>>> Can anybody help?
>>> 
>>> Cheers, Peter
>> 
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: [email protected]
>> For additional commands, e-mail: [email protected]
>> 
>> 
>> 
> 
> 

-- 
View this message in context: 
http://www.nabble.com/Compiling-XLSX2CSV-example-using-XSSF-tp25829140p25835723.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