Discussion:
Compiling XLSX2CSV example using XSSF
peterconn
2009-10-09 23:00:56 UTC
Permalink
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
--
View this message in context: http://www.nabble.com/Compiling-XLSX2CSV-example-using-XSSF-tp25829140p25829140.html
Sent from the POI - User mailing list archive at Nabble.com.
Chris Lott
2009-10-10 00:25:00 UTC
Permalink
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.
Post by peterconn
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
David Fisher
2009-10-10 00:35:13 UTC
Permalink
Chris,

We appreciate your contributions!

Regards,
Dave
Post by Chris Lott
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
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.
Post by peterconn
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
---------------------------------------------------------------------
peterconn
2009-10-10 04:03:20 UTC
Permalink
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
Post by Chris Lott
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
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.
Post by peterconn
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
---------------------------------------------------------------------
--
View this message in context: http://www.nabble.com/Compiling-XLSX2CSV-example-using-XSSF-tp25829140p25830841.html
Sent from the POI - User mailing list archive at Nabble.com.
MSB
2009-10-10 16:12:20 UTC
Permalink
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
Post by David Fisher
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
Post by Chris Lott
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
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.
Post by peterconn
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
---------------------------------------------------------------------
--
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.
Bobby Kent
2009-10-10 00:28:06 UTC
Permalink
Hey Peter,

Did the same and I think I understand the issue. The package line at the
start of the java files are needed unless you make further code changes. To
fix the issue, unzip the file you downloaded from
http://chris-lott.org/software/, and create the directory tree
org\chris_lott\xlsx2csv (on Windows) or org/chris_lott/xlsx2csv (on *nix).
Move the unzipped java files into the xlsx2csv directory but do not change
to this directory. From the parent directory of org type:

javac org/chris_lott/xlsx2csv/XLSX2CSV.java (works on Windows and *nix)

then

java org.chris_lott.xlsx2csv.XLSX2CSV workbook.xlsx

changing workbook.xlsx to the path and name for the workbook you wish to
convert to csv.

HTH,

Bobby

-----Original Message-----
From: peterconn [mailto:***@vedaadvantage.com]
Sent: Friday, October 09, 2009 19:01
To: ***@poi.apache.org
Subject: Compiling XLSX2CSV example using XSSF


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
--
View this message in context:
http://www.nabble.com/Compiling-XLSX2CSV-example-using-XSSF-tp25829140p25829
140.html
Sent from the POI - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: user-***@poi.apache.org
For additional commands, e-mail: user-***@poi.apache.org
Loading...