Hello Aaron,
Yes, I'm doing the conversion in php, calling the CL utility xls2csv and
taking
its output and writing it to file.
Code included. I removed my processing on the data, since I don't know what
you want
to do with it. This partial script goes through each file in the target
director and converts from
.xls to /converted/.csv
You can do as you please after. Its got libs that aren't open source though.
If you need access to particular function calls or classes, let me know.
So, yeah, this script isn't of much use to you I guess. Sorry.
- Ben
Ben Sgro, Chief Engineer
ProjectSkyLine - Defining New Horizons
Our company: www.projectskyline.com
Our products: www.project-contact.com
This e-mail is confidential information intended only for the use of the
individual to whom it is addressed.
----- Original Message -----
From: "Aaron Fischer" <[EMAIL PROTECTED]>
To: "NYPHP Talk" <talk@lists.nyphp.org>
Sent: Monday, August 20, 2007 11:28 AM
Subject: Re: [nyphp-talk] Reading an excel file with PHP
Hi Ben,
I've been looking into working with csv. That seems like a nice way to
go. Do you use PHP to convert the .xls files to .csv? Yes, I'd be
interested in source. Thanks Ben.
-Aaron
On Aug 20, 2007, at 11:19 AM, Ben Sgro ((ProjectSkyLine)) wrote:
Hello Aaron,
I convert .xls files to .csv files and then do parsing/manipulation.
I can include source if you want it.
- Ben
_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php
<?php
/*!
@copyright
Copyright (c) ProjectSkyLine LLC with operations in NH & NY, 2005-2007.
All Rights Reserved. Unpublished rights reserved under the
copyright laws of the United States.
This software and any other software contained on this media
is proprietary to and embodies the confidential technology
of ProjectSkyLine LLC. Possession, use, duplication or
dissemination of the software and media is authorized only
pursuant to a valid written license from ProjectSkyLine LLC.
Written by: Ben (sk) Sgro, ProjectSkyline[dot]com, 2007.
s-k * #projectskyline * irc.efnet.net * 6667
fakie: The main file. This application is currently under
development. Confidential TM of Ben Sgro, ProjectSkyLine
Chief Engineer.
Not to be released.
When: Who: What:
----- ---- -----
21-Jul-07 BJS Created.
*/
$OOP_INC_PATH = '../OOPLIB/';
$CURRENT_PATH = $_SERVER["PHP_SELF"]; /* sifter/sifter.php */
/* Keep include files this order. */
include($OOP_INC_PATH . 'CONS.php');
include($OOP_INC_PATH . 'ERRO.php');
include($OOP_INC_PATH . 'UTIL.php');
define('CONVERTED_DIR', '/converted');
define('XLS_EXT', 'xls');
define('CSV_EXT', 'csv');
/* Grab the arguments */
$ARGV = getopt('d:');
$directory = @ $ARGV['d'];
if ( count($ARGV) != 1 )
{
printf("Usage: sifter.php -d /target/directory\n");
exit;
}
/* MAIN */
$utilityObject = new Utility( );
$fileCount = 0;
/* From the -d, create the "converted" directory.
/var/www/html/sk/data then we create
/var/www/html/sk/data/converted
*/
$convertedDirectory = $directory . CONVERTED_DIR;
if ( $utilityObject->MakeDirectory($convertedDirectory, 0777) == FALSE )
{
printf("Directory already exists\n");
}
/* Convert all .xls files to .csv files. */
$filesSet = $utilityObject->ListFilesIn($directory);
while(list($index, $value) = each($filesSet))
{
if ( $utilityObject->CheckExtension(XLS_EXT, $value) == TRUE )
{
/* Remove XLS_EXT from file. */
$fileName = substr($value, 0, strlen($value)-3);
$fileName .= CSV_EXT;
/* Create the same name file, but with the .csv extension. */
$fHandle = $utilityObject->OpenFile($convertedDirectory . '/' . $fileName,
"w");
/* Convert the .xls to .csv. */
//echo "xls2csv $directory${value}\n\n";
$tmpCSV = shell_exec("xls2csv $directory${value}");
/* Save the output of xls2csv to converted file. */
$utilityObject->WriteFile($fHandle, $tmpCSV);
/* Close the file handle. */
$utilityObject->CloseFile($fHandle);
}
}
Code here...
?>_______________________________________________
New York PHP Community Talk Mailing List
http://lists.nyphp.org/mailman/listinfo/talk
NYPHPCon 2006 Presentations Online
http://www.nyphpcon.com
Show Your Participation in New York PHP
http://www.nyphp.org/show_participation.php