<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
</head>
<body text="#000000" bgcolor="#FFFFFF">
This is probably old news to some out there, but I thought this was
pretty cool.<br>
Those of you using Windows, I am sure you can adapt this technique
easily.<br>
<br>
1) Downlaod PHPExcel zip file from <a moz-do-not-send="true"
href="https://github.com/PHPOffice/PHPExcel/releases">https://github.com/PHPOffice/PHPExcel/releases</a><br>
2) Make a folder under your web directory, i.e. /var/www/html, named
Classes.<br>
3) Extract the zip download into that folder. <br>
<br>
You should end up with a directory under Classes named PHPExcel and<br>
a file PHPExcel.php.<br>
<br>
Here is the php script. Save it to /var/www/html/convert.xlsx.php<br>
<br>
<font face="Courier New, Courier, monospace"><?php<br>
error_reporting(E_ALL);<br>
ini_set('display_errors', TRUE);<br>
ini_set('display_startup_errors', TRUE);<br>
//** auto-sense convert<br>
//** if file1 is .csv and file2 is .xlsx, with create the .xlsx<br>
//** if file1 is .xlsx and file2 is .csv, with create the .csv<br>
$file1 = $argv[1];<br>
$file2 = $argv[2];<br>
/** Include PHPExcel */<br>
require_once 'Classes/PHPExcel.php';<br>
$objPHPExcel = PHPExcel_IOFactory::load($file1);<br>
$objWriter = PHPExcel_IOFactory::createWriter($objPHPExcel,
'Excel2007');<br>
$objWriter->save($file2);<br>
?><br>
</font><br>
Here is the Linux script, /usr/local/bin/convert_xlsx<br>
<font face="Courier New, Courier, monospace">#This will convert a
xlsx to csv and/or convert a csv to xlsx<br>
#file1 is the loaded file<br>
#file2 with an extension will determine the output formatted file<br>
#<br>
# Please note the arguments MUST be enclosed in quotes<br>
#i.e. /usr/bin/php /var/www/html/convert_xlsx.php "/tmp/file.xlsx"
"/tmp/file.csv"<br>
#will create a CSV file from the XLSX file.<br>
#<br>
#i.e. /usr/bin/php /var/www/html/convert_xlsx.php "/tmp/file.csv"
"/tmp/file.xlsx<br>
#will create a XLSX file from the CSV file.<br>
#<br>
/usr/bin/php /var/www/html/convert_xlsx.php "$1" "$2"</font><br>
<br>
To handle .xls file types, change the .xlsx to .xls and change
'Excel2007' to 'Excel2005'<br>
and save it to /usr/local/bin/convert.xls<br>
<br>
This PHPExcel class is very powerful and I have now experimented
with it's suptantail capabilities. I now you can foramt cells for
color, width, etc..<br>
I just needed to do a conversion of my filepro csv files to xlsx.<br>
<br>
My filepro command is;<br>
<font face="Courier New, Courier, monospace">system
"/usr/local/bin/convert_xlsx \"file1.csv\" \"file2.xlsx\"";<br>
</font><br>
Hope this helps somebody,<br>
<br>
Richard D. Williams<br>
<br>
</body>
</html>