Link to home
Start Free TrialLog in
Avatar of perrosucio
perrosucio

asked on

Writing info from a database into a pre-defined excel template

Hi,

I am having problems when trying to write information into excel. First of all, I was provided with an excel template (It has an image, some cells shaded, and colors).

My question is, can I open the pre-defined template and write into it and prompt the user to open or save it with a different name? If yes, how can I do this.

I was suggested to use BIFFwriter, to create the template and then write into it. Unfortunately, this solution does not allow me to insert an image (logo) into the excel file.

I am running out of solution to this. Can someone give a hand or at least tell me if this could be done.

Thank you very much.

Andy
Avatar of AlanJDM
AlanJDM

"Unfortunately, this solution does not allow me to insert an image (logo) into the excel file."

You most certainly can insert an image with BIFFWriter...

$worksheet->InsertBitmap(0,0, 'image.bmp');



Alan
I'll tell you what... send your template to me at the address in my profile and I'll have a look at it. Depanding on how complex it is I will write something for you and send it back. It may not be the whole script, but at least enough to get you started.


Alan
Avatar of perrosucio

ASKER

Hi Alan,

I already sent you the template. The template is not complicated. The thing is that the Biffwriter that I downloaded is encrypted and only works with ZEND. Therefore I can´t change anything about the class. I can only invoque the methods.

Thank you very much,

Andy
First, I didn't recieve any email from you. Second, I have no idea what this means "Biffwriter that I downloaded is encrypted". Biffwriter is part of pear and is included in newer versions of PHP. No Zend needed. I will watch for your email.

For your reference...

http://pear.php.net/
http://pear.php.net/package/Spreadsheet_Excel_Writer#results
http://pear.php.net/package/Spreadsheet_Excel_Writer/docs/0.4/Spreadsheet_Excel_Writer/Spreadsheet_Excel_Writer_BIFFwriter.html


Alan
I also don't understand this... "Therefore I can´t change anything about the class". Why do you feel you need to change the classes? Everything you have said you need to do can be done by simply invoking the methods already defined in the class.


Alan
Can I set the color of a cell to blue (I mean the filling)??

Were can I download the latest version of the BIFFwriter class? Which version do you have?

Andy
I just sent it again. The subject says FROM Experts-Exchange.

Thank you very much

Andy
Now I am confused.

I downloaded the class made by Novak in one of the links you suggested me. The zip that I got contains biff.php and biffbase.php. I cannot read the content of the classes.

Could you please tell me which version should I get, because I was reading the link from PEAR and I dowloaded something called spreadsheet.tgz

Thanks,

Andy
I have no idea what version I am using because I didnt install it. It is part of PHP. It is installed as part of the PHP install. I can tell you I am running php ver. 4.3.4. Beyond that, I don't know.

Are you sure it isn't already installed and you just dont realize it?


Alan
I have to check the version of PHP I am using. It is more than obvious that I have little or no experience with PHP, and so far the things I have done are very simple, nothing complex so far. As you can see I have no idea on how to use the Biffwriter.

You said "Biffwriter is part of pear and is included in newer versions of PHP".  Here is were I get confused, how do I work with this? Should I include PEAR.php ????

Thanks

Andy
this is all you need to include...

include_once('/usr/local/lib/php/Spreadsheet/Excel/Writer.php');

This is also how you can check and see if you have the package installed, just check and see if that file is on your system. If it is than you are good to go, if not then you don't have what you need to use biffwriter.


Alan
First of all,

I am running  php ver. 4.3.3

From what I see from your last comment, you are running on UNIX. I am using Apache in windows. What should I include??

Also, where can I find the API that shows the method required for including images, cell format, etc.

Thanks,

Andy

P.D, Did you get my e-mail????

ASKER CERTIFIED SOLUTION
Avatar of AlanJDM
AlanJDM

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ok, I have been checking the directory where the PHP was installed. I went to the "lib" directory, but nothing about PHP or "Spreadsheet" appears there.

I have to look better, otherwise I'll have to download the latest version of PHP.

I will let you know once I am ready to go.

Andy
From your windows start menu click on "search" or "find" depending on what version of win you have and simply search the whole file system for the file. No need to waste time manually searching each directory.

Alan



I have searched the whole thing and no results for "Writer.php".

Could´nt  I just download the Writer.php and save it on my working directory?? Or do I need more things?

Andy
No, there are a lot of other files needed.

You may want to inquire from some windows group(s) if this is even part of the windows package. Maybe its a unix specific tool. I have always taken it for granted because I have always used unix.


Alan
Hi Alan,

I have been reading in order to know if this is available for windows and I came across the following website:

http://www.sitepoint.com/article/pear-spreadsheet_excel_writer

"This is written in pure PHP and will work just as well from a UNIX-based Web server as it does from a Windows-based server -- and there's no need to bug your hosting provider."

The above is an exact quote of the article.

I will download the lates version of PHP and I´ll post back.

Andy
Hi Alan,

I just got a package called "Spreadsheet_Excel_Writer-0.8" and its content is:

Writer.php and a folder called Writer that has:

BIFFwriter.php
Parser.php
Workbook.php
Format.php
Validator.php
Worksheet.php

I don't know if this is all I need, please let me know if I can use this.

Thanks,

Andy
Run this as a test, changing the include path to where ever your files are kept...

<?php

  include_once '/usr/local/lib/php/Spreadsheet/Excel/Writer.php';

  $workbook = new Spreadsheet_Excel_Writer('test.xls');
  $worksheet =& $workbook->addWorksheet('test');
  $worksheet->write(0,0,'testing 123');
  $workbook->close();

?>


Alan
I've got the write method to work I had to download few extra things like OLE.php, PPS.php

The thing now is that I am receiving Warnings when using the BIFFwriter.

Without warnings, I tried to insert a Bitmap but is not working. I have to stop the Apache and Start it again.
It sounds like the windows version of this product runs a little differently then the unix version. the script I posted runs without warnings here. As does this one that inserts a bitmap...


<?php

  include_once '/usr/local/lib/php/Spreadsheet/Excel/Writer.php';

  $workbook = new Spreadsheet_Excel_Writer('test.xls');
  $worksheet =& $workbook->addWorksheet('test');
  $worksheet->insertBitmap(0,0,'test.bmp');
  $workbook->close();

?>


Alan
Hi Alan,

Images and text is working fine, I made a silly mistake and that is why the insertBitmap was not working. I tried formats and they are working just fine.

Everything is ready to go. If you have time could you please help me with the template I sent you by e-mail?

Thank you very much

Andy
I have solve the warnings, they were related to the headers, but now they are not present.

Andy
Hi Alan,

I don't know which e-mail did you receive, because I sent it twice (from to different e-mail addresses). Either case, the template I need help with is the one from the worksheet called "Formato Puntos TIM". Once I understand the whole thing, I should be able to do the remaining templates.

Thank you very much for all the help.

Andy
Done, everything is working fine.

Thanks for all your help.

Andy