Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Convert XLS to CSV using PHP on Linux Apache server

Posted on 2008-10-18
4
Medium Priority
?
6,061 Views
Last Modified: 2013-12-13
I have an exisitng web app written in PHP, that allows the user to upload a csv file and it imports the data into a mysql table.

My client is now complaining about converting xls files to csv.  Is there a script or linux program that I can run on the server that would convert the excel spreadsheet to csv on the web server?

Then my client could just upload the xls files and be done with it?

What about a linux based conversion of xlsx files to csv??
0
Comment
Question by:fastfind1
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 

Author Comment

by:fastfind1
ID: 22749889
I have found on source_forge something called Spreadsheet_Excel_Reader.  I tried the following code to try and get a csv file to pop out from the xls file, but it is not working.  Can anyone see the error in my code?
<?php
 
require_once 'reader.php';
$data = new Spreadsheet_Excel_Reader();
$data->setOutputEncoding('CP1251');
$data->read('closing/closing.xls');
 
?>

Open in new window

0
 
LVL 51

Expert Comment

by:Steve Bink
ID: 22752658
The Spreadsheet_Excel_Reader class is not well-documented.  In fact, I could find no documentation for it at all.  But I believe it only reads an Excel file.

What error are you receiving with your code?
0
 

Author Comment

by:fastfind1
ID: 22755955
No error - but no result.

Maybe Spreadsheet_Excel_reader is not what I want.

Anyone have a solution for converting xls files to csv files on a linux server - using a PHP script, or something similar?
0
 
LVL 51

Accepted Solution

by:
Steve Bink earned 2000 total points
ID: 22758274
>>> No error - but no result.

I would expect not, seeing as how your code only reads the file.  Once you have the data from the file, you'll need to reorganize it into rows of comma-delimited text.  

See here for a brief tutorial on using the reader class.  It also talks about the writer class, but that should not be necessary for your purposes:

http://devzone.zend.com/article/3336-Reading-and-Writing-Spreadsheets-with-PHP
0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

715 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question