How to convert .xls file into text file.

  • Thread starter Thread starter pappu
  • Start date Start date
P

pappu

Hello friends,

I want to convert .xls file into text file.So can anybody pls
help me out.

Thxxxxxx,
Sachin.
 
Hi Sachin,

You can convert excel files to comma separated files in several ways. You
can do it directly from Excel in save as, using the office API (requires
Excel installed)

ThisApplication.ActiveWorkbook.SaveAs("c:\\MyWorkbook.xml",
Excel.XlFileFormat.xlCSVMSDOS, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing, Type.Missing);

Or using an OleDB provider and write your custom method for reading excel
files and outputting as text files.
 
Hi,

Morten said:
Hi Sachin,

You can convert excel files to comma separated files in several ways.
You can do it directly from Excel in save as, using the office API
(requires Excel installed)

ThisApplication.ActiveWorkbook.SaveAs("c:\\MyWorkbook.xml",
Excel.XlFileFormat.xlCSVMSDOS, Type.Missing, Type.Missing,
Type.Missing, Type.Missing, Excel.XlSaveAsAccessMode.xlNoChange,
Type.Missing, Type.Missing, Type.Missing, Type.Missing,
Type.Missing);

We miss the context, but it's always good to mention that Microsoft
explicitly recommends against server-side automation of Office.
http://support.microsoft.com/kb/257757
Or using an OleDB provider and write your custom method for reading
excel files and outputting as text files.

I like that option much better.
http://geekswithblogs.net/lbugnion/archive/2006/08/25/89315.aspx

HTH,
Laurent
 
To speak from one's own experience there is often no necessity to read
the xls-file. If you only want to get data of one table inside the
xls-file just export it to csv-file.
 
Hi,
To speak from one's own experience there is often no necessity to read
the xls-file. If you only want to get data of one table inside the
xls-file just export it to csv-file.

Isn't it like saying "To speak from experience, one often doesn't need a
car, one can walk". I think it really depends on the situation. I see
one case at least where using an Excel file instead of a CSV file makes
sense: Mobile environments (in my case, Palm PDAs) support editing
native Excel files, but do not support exporting to CSV. In that case,
reading an Excel file from a NET application is needed. Additionally,
Excel can only export one sheet to a CSV file, not all sheets. For
multiple sheets, additional work is needed to merge multiple CSV files
to one before reading them.

Based on my own experience, it's not possible to generalize :-)

Greetings,
Laurent
 
We miss the context, but it's always good to mention that Microsoft
explicitly recommends against server-side automation of Office.
http://support.microsoft.com/kb/257757

That's true, but the OP doesn't specifically mention server-side - he
certainly doesn't mention ASP.NET... WinForms automation is perfectly OK...

Or even this, if more functionality is required:
http://www.aspose.com/Products/Aspose.Cells/Default.aspx
 
Hi,

Extremely easy to do, read the excel file using OleDB (google the code for
this)
and just export it like csv.

Send me an email if you are too lazy to find the code
 
Hi
Morten Wennevik said:
Hi Sachin,

You can convert excel files to comma separated files in several ways. You
can do it directly from Excel in save as, using the office API (requires
Excel installed)

I think that this is like shooting a fish with a cannon, using OleDB you can
read the file as a datasource and simply write down a csv file with just a
few lines of codes
 
hi

what if he neeeds to do this in a service? or do this everyday at midnight?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top