Jump to content

Excel writer problems


ShadowMage

Recommended Posts

Hey guys, I've got a question for you.I just downloaded an Excel reader/writer class and I've been working with it to test it out. Unfortunately I can't get it to work at all. Here's the link where I downloaded this from: http://www.phpclasses.org/package/1919-PHP...xcel-files.htmlAnd here's the code I'm using to test it:

require_once('excel.php');$file = 'xlsfile://test.xls';$resource = fopen($file, 'wb');if (!$resource) {	die("Couldn't open ".$file);}$arrTest1 = array(	array("Test1" => 1, "Test2" => 2, "Test3" => 3),	array("Test4" => 4, "Test5" => 5, "Test6" => 6),	array("Test7" => 7, "Test8" => 8, "Test9" => 9));$arrTest2 = array(	array("col1", "col2", "col3", "col4", "col5"),	array("col6", "col7", "col8", "col9", "col10"));fwrite($resource, serialize($arrTest1));fclose($resource);?>

I keep getting this error:Notice: Undefined index: path in c:\Inetpub\phplib\excel.php on line 74Line 74 is this:

function stream_open($path, $mode, $options, &$opened_path)	{		$url = parse_url($path);		$this->xlsfilename = '/' . $url['host'] . $url['path']; //<-- This is line 74		$this->position = 0;		$this->mode = $mode;		...}

$path refers to $file = 'xlsfile://test.xls';So my question is this: Am I forming that path correctly? If I change it to something like 'xlsfile://excel_test/test.xls' or even 'xlsfile://webportal.major.com/Test/test.xls' then I get the following error:Warning: fopen(xlsfile://excel_test/test.xls) [function.fopen]: failed to open stream: "xlsStream::stream_open" call failed in C:\Inetpub\major\Test\ExcelTest.php on line 5Test is the folder where I have my test.php file. excel_test is a folder I created in the Test folder. The only way I don't get the 'failed to open stream' error is if I do it this way: 'xlsfile://test.xls'I even tried creating text.xls both in the Test folder and in Test/excel_test which didn't change anything. Can someone help me please?

Link to comment
Share on other sites

It's not complaining about the $path variable, it's complaining about the "path" string index of $url (specifically, that it doesn't exist).Anyway, I don't see anywhere in your main code where you call stream_open().

Link to comment
Share on other sites

Try to pass in the full (absolute) path to the file. It seems this wrapper doesn't respect the cwd.Also, see what's actually in $path (i.e. before it turns into an array), and see if you can debug that.Last but not least, I highly suggest you contact the author about this problem, hopefully with a suggested solution too. As someone who has developed a class himself, I find it somewhat insulting for developers to have headaches over my code, and not bother at least telling me about it.

Link to comment
Share on other sites

It's not complaining about the $path variable, it's complaining about the "path" string index of $url (specifically, that it doesn't exist).Anyway, I don't see anywhere in your main code where you call stream_open().
stream_open() is called automatically by the xlsStream class in excel.php whenever fopen() is called using the xlsfile: wrapper.
Try to pass in the full (absolute) path to the file. It seems this wrapper doesn't respect the cwd.Also, see what's actually in $path (i.e. before it turns into an array), and see if you can debug that.Last but not least, I highly suggest you contact the author about this problem, hopefully with a suggested solution too. As someone who has developed a class himself, I find it somewhat insulting for developers to have headaches over my code, and not bother at least telling me about it.
By absolute path you mean something like 'webportal.major.com/Test/text.xls'? Did that. I get an error saying that it failed to open the stream.And I completely agree with your last statement. I, too, would find that somewhat insulting. I'll be sure to let him know. :)
Link to comment
Share on other sites

I meant an absolute file path... like "D:\Documents\Test\text.xls".

Link to comment
Share on other sites

I meant an absolute file path... like "D:\Documents\Test\text.xls".
Oh, I gotcha.I tried that and it produced these two errors:Warning: parse_url(xlsfile://C:Inetpub/major/Test/test.xls) [function.parse-url]: Unable to parse url in c:\Inetpub\phplib\excel.php on line 73Warning: fopen(xlsfile://C:Inetpub/major/Test/test.xls) [function.fopen]: failed to open stream: "xlsStream::stream_open" call failed in C:\Inetpub\major\Test\ExcelTest.php on line 5
Link to comment
Share on other sites

Odd... but why the "C:Interput" part? It should've been "xlsfile://C:\Inetpub\major\Test\test.xls" or "xlsfile://C:/Inetpub/major/Test/test.xls" (the slash after "C:" being the crutial part).And again, try to do some debugging in the stream_open() method, var_dump()-ing stuff, etc.

Link to comment
Share on other sites

Odd... but why the "C:Interput" part? It should've been "xlsfile://C:\Inetpub\major\Test\test.xls" or "xlsfile://C:/Inetpub/major/Test/test.xls" (the slash after "C:" being the crutial part).
:) I missed a slash! Let me try that again.Edit: Ok, still doesn't work. I'll start some debugging and var_dumping and stuff to see what I can come up with.I contacted the author, so I'll have to wait and see what he says.
Link to comment
Share on other sites

Well, I decided to abandon this one since I can't figure out why it's not working.I actually found a different file for PEAR.http://pear.php.net/package/Spreadsheet_Ex...Writer/downloadI also needed to download the OLE files too.[http://pear.php.net/package/OLE/downloadThese work beautifully. Thanks for the help though!

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...