[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 258
  • Last Modified:

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
0
perrosucio
Asked:
perrosucio
  • 15
  • 11
1 Solution
 
AlanJDMCommented:
"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
0
 
AlanJDMCommented:
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
0
 
perrosucioAuthor Commented:
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
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.

 
AlanJDMCommented:
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
0
 
AlanJDMCommented:
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
0
 
perrosucioAuthor Commented:
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
0
 
perrosucioAuthor Commented:
I just sent it again. The subject says FROM Experts-Exchange.

Thank you very much

Andy
0
 
perrosucioAuthor Commented:
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
0
 
AlanJDMCommented:
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
0
 
perrosucioAuthor Commented:
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
0
 
AlanJDMCommented:
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
0
 
perrosucioAuthor Commented:
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????

0
 
AlanJDMCommented:
I cant help you with what to include on windows because I have never used this product on windows. Search your system for the file named writer.php. If you find it, thats what you include.

complete pear manual...
http://www.piskov.net/pear_manual/index.html

excel writer(biffwriter) specific manual...
http://www.piskov.net/pear_manual/package.fileformats.spreadsheet-excel-writer.html

Yes, I got your email, but I'm not going to spend any time working on a script until you are sure you will be able to use it. Let me know when you have confirmed weather or not you have all the pear/excel writer mods available and I will do a script for you.


Alan


0
 
perrosucioAuthor Commented:
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
0
 
AlanJDMCommented:
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



0
 
perrosucioAuthor Commented:
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
0
 
AlanJDMCommented:
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
0
 
perrosucioAuthor Commented:
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
0
 
perrosucioAuthor Commented:
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
0
 
AlanJDMCommented:
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
0
 
perrosucioAuthor Commented:
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.
0
 
AlanJDMCommented:
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
0
 
perrosucioAuthor Commented:
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
0
 
perrosucioAuthor Commented:
I have solve the warnings, they were related to the headers, but now they are not present.

Andy
0
 
perrosucioAuthor Commented:
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
0
 
perrosucioAuthor Commented:
Done, everything is working fine.

Thanks for all your help.

Andy
0

Featured Post

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

  • 15
  • 11
Tackle projects and never again get stuck behind a technical roadblock.
Join Now