echo three columns of row2

file is
xlxs

viewing using microsoft excel there are 3 columns and many rows
but using notepad or php ide text is not readable

want to use php to gather info from
3 columns



I do not want to view file
I want to use php to echo the three columns of row2

maybe use
lib like phpExcel
LVL 1
rgb192Asked:
Who is Participating?
 
Ray PaseurConnect With a Mentor Commented:
Looks like it cannot find the file.
( ! ) Warning: fopen(countries_and_population.xlsx) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 191
0
 
BenefordCommented:
If you want to open an Excel file in a text-based editor (like Notepad), try changing the file type when you save it - File Save As, Save As Type: set to Text or CSV.
0
 
Loganathan NatarajanLAMP DeveloperCommented:
0
Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
Loganathan NatarajanLAMP DeveloperCommented:
0
 
gr8gonzoConsultantCommented:
PHP Excel Reader will not work for this situation. It is a good library but it is meant for the old binary format XLS, not for the new XLSX format. The new XLSX format is actually a renamed ZIP file. If you rename the extension to .ZIP, you can open it and see that it's a bunch of XML documents and various small files inside.

That said, I don't know of an XLSX reader off the top of my head, but you COULD use ODBC to do this.

1. Add a new data source to your machine that uses the XLSX file as its source (if you want to access it regularly - otherwise you can pass the filename in on the ODBC data source name string)
2. Use PHP's ODBC or PDO extensions to connect to the data source:

ODBC extension:
http://www.ibm.com/developerworks/opensource/library/os-php-odbc/index.html

PDO extension:
http://stackoverflow.com/questions/11026002/pdo-query-database-odbc
0
 
Ray PaseurCommented:
@gr8gonzo: An XLSX reader extension would be a wonderful contribution to the community!

@rgb192: I would choose the "save as CSV" option.  I think it would be the path of least resistance.  PHP already has the fgetcsv() function baked in. To get to row #2, you might do something like this (untested but probably correct in principle):

<?php
$fp = fopen('path/to/csv_file', 'r');
if ($fp)
{
    $dat = fgetcsv($fp);
    $dat = fgetcsv($fp);
    var_dump($dat);
    // etc...
}

Open in new window

HTH, ~Ray
0
 
rgb192Author Commented:
Rays code
the exact unreadable output of xlxs file


I dont know how to implements these
ODBC extension:
http://www.ibm.com/developerworks/opensource/library/os-php-odbc/index.html

PDO extension:
http://stackoverflow.com/questions/11026002/pdo-query-database-odbc


why wont php excel reader work




i have to read column 2 (internal order number for our product) and column3 (external shipping tracking number)

at least once a day


I get this file from ftp


is there is a way I can convert xlxs to csv
without manually opening file in excel and save as
0
 
Ray PaseurCommented:
This might be something of a research project, but there might be something you can adapt here:
http://www.phpkode.com/scripts/item/simple-xlsx/
0
 
rgb192Author Commented:
running
http://www.phpkode.com/scripts/item/simple-xlsx/


http://localhost:81/simple-xlsx-0.4/simplexlsx.example.php

this is the browser output

( ! ) Warning: filemtime() [function.filemtime]: stat failed for countries_and_population.xlsx in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 185
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31
4	0.0033	848256	filemtime ( )	..\simplexlsx.class.php:185

( ! ) Warning: filesize() [function.filesize]: stat failed for countries_and_population.xlsx in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 186
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31
4	0.0039	848920	filesize ( )	..\simplexlsx.class.php:186

( ! ) Warning: fopen(countries_and_population.xlsx) [function.fopen]: failed to open stream: No such file or directory in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 191
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31
4	0.0044	849640	fopen ( )	..\simplexlsx.class.php:191

( ! ) Warning: fread() expects parameter 1 to be resource, boolean given in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 192
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31
4	0.0049	850088	fread ( )	..\simplexlsx.class.php:192

( ! ) Warning: fclose() expects parameter 1 to be resource, boolean given in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 193
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31
4	0.0052	850152	fclose ( )	..\simplexlsx.class.php:193

( ! ) Notice: Undefined offset: 1 in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 198
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31

( ! ) Warning: unpack() [function.unpack]: Type x: not enough input, need 1, have 0 in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 198
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31
4	0.0056	850696	unpack ( )	..\simplexlsx.class.php:198

( ! ) Notice: Undefined offset: 1 in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 199
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0033	847664	SimpleXLSX->_unzip( )	..\simplexlsx.class.php:31

( ! ) Notice: Trying to get property of non-object in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 348
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0160	849520	SimpleXLSX->_parse( )	..\simplexlsx.class.php:32

( ! ) Warning: Invalid argument supplied for foreach() in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 348
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0032	847664	SimpleXLSX->__construct( )	..\simplexlsx.example.php:5
3	0.0160	849520	SimpleXLSX->_parse( )	..\simplexlsx.class.php:32
$xlsx->rows()



( ! ) Fatal error: Uncaught exception 'Exception' with message 'Worksheet 1 not found.' in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 53
( ! ) Exception: Worksheet 1 not found. in C:\wamp\www\simple-xlsx-0.4\simplexlsx.class.php on line 53
Call Stack
#	Time	Memory	Function	Location
1	0.0008	674232	{main}( )	..\simplexlsx.example.php:0
2	0.0347	850024	SimpleXLSX->rows( )	..\simplexlsx.example.php:8
3	0.0347	850072	SimpleXLSX->worksheet( )	..\simplexlsx.class.php:65

Open in new window

0
 
rgb192Author Commented:
works when I place file in directory

thanks

I have a followup question

http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_27874313.html
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.