You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Ashwani Mayur <as...@fanniemae.com> on 2003/08/27 14:44:59 UTC

How to convert .xls file to .csv format file using POI

I am seeking  help to convert few of my .xls files to .csv format.
Is there any existing function in the POI for this job?

Thanks for any help
Ashwani



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


Re: How to convert .xls file to .csv format file using POI

Posted by Avik Sengupta <av...@apache.org>.
Oh, well.. you said few ...:)

Processing Excel files on the server side is what poi does best... so
yes, it is certainly possible to do it in poi. However, POI is a file
format reader, so it doesnt have any application level code it in ..
(and for good reason too, imo!)

So POI will give you programmatic access to the excel file, and its your
job to extract the data. The complexity of that code is primarily a
function of the complexity of the sheet. For a simple sheet, it should
be about five lines of code. Check the POI website, particularly the FAQ
and HSSF sections, and see the examples directory of the distribution.

Note also, that POI is best used for reading if you can have a modicum
of control over the format of the sheets sent to you. It is certainly
possible to throw a sheet at POI that makes it barf, but if you do
proper error handling, you should be OK. And yes, lots of people DO use
it in production. 

If you get stuck, ask on the lists. 

Regards
-
Avik


On Wed, 2003-08-27 at 18:55, Ashwani Mayur wrote:
> Avik,
> Thanks for a quick reply. My client gets approx 500 files every day on a
> unix file server and
> would like us to process them based on some logic and then load the data in
> Oracle database.
> I was wondering if it could be possible to convert the files
> programatically in csv format using POI ?
> 
> Thanks
> Ashwani
> 
> 
> Avik Sengupta wrote:
> 
> > There is a Save As function in Excel.. wont that do?
> > On Wed, 2003-08-27 at 18:14, Ashwani Mayur wrote:
> > > I am seeking  help to convert few of my .xls files to .csv format.
> > > Is there any existing function in the POI for this job?
> > >
> > > Thanks for any help
> > > Ashwani
> > >
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > > For additional commands, e-mail: poi-user-help@jakarta.apache.org
> > >
> > --
> > Avik Sengupta <av...@apache.org>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 
-- 
Avik Sengupta <av...@apache.org>


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


Re: How to convert .xls file to .csv format file using POI

Posted by Ashwani Mayur <as...@fanniemae.com>.
Avik,
Thanks for a quick reply. My client gets approx 500 files every day on a
unix file server and
would like us to process them based on some logic and then load the data in
Oracle database.
I was wondering if it could be possible to convert the files
programatically in csv format using POI ?

Thanks
Ashwani


Avik Sengupta wrote:

> There is a Save As function in Excel.. wont that do?
> On Wed, 2003-08-27 at 18:14, Ashwani Mayur wrote:
> > I am seeking  help to convert few of my .xls files to .csv format.
> > Is there any existing function in the POI for this job?
> >
> > Thanks for any help
> > Ashwani
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: poi-user-help@jakarta.apache.org
> >
> --
> Avik Sengupta <av...@apache.org>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org



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


Re: How to convert .xls file to .csv format file using POI

Posted by Ashwani Mayur <as...@fanniemae.com>.
Amon,

I was moving on that direction and bumped into few problems .
1. In the usermodel, I was not able to read the formula fields. Infact I
could not find any function that could read the value of the formula column
for me in the UserModel (I am sure there will be some valid reason for
that). The getCellFormula() function provides me the formula name and this
one does not work when the user have copy pasted the formula from one row
to the rest of the rows.
>From one of the archived mails I came to know that this is an issue (might
get fixed in future) with the formula fields in the present versions.

2. When I tried the eventmodel, I was able to read the formula values
without any problem but date fields were the problem. There are various
subclasses of the org.apache.poi.hssf.record.Record class including the
FormulaRecord but I am having hard time to read the date field because I
could not find the DateRecord or equivalent class to read the date format
fields.
In the utility class there is one function to read the date format but that
takes HSSFCell as an input and I am still not able to figure out how to
pass a record to this util class to get the date field.

Also as I already metioned that my requirement was only to read the data
from the selected columns and not to do any formula manipulation so I
though that conversion to CSV could be one of the possiblities to read.

Once again I do appreciate the hard work put in by the folks in this
project and the qucik replies from every one

Ashwani





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


Re: How to convert .xls file to .csv format file using POI

Posted by Avik Sengupta <av...@apache.org>.
There is a Save As function in Excel.. wont that do?
On Wed, 2003-08-27 at 18:14, Ashwani Mayur wrote:
> I am seeking  help to convert few of my .xls files to .csv format.
> Is there any existing function in the POI for this job?
> 
> Thanks for any help
> Ashwani
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: poi-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: poi-user-help@jakarta.apache.org
> 
-- 
Avik Sengupta <av...@apache.org>


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