?
Solved

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

Posted on 2005-03-15
26
Medium Priority
?
251 Views
Last Modified: 2013-12-12
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
Comment
Question by:perrosucio
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 15
  • 11
26 Comments
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13549013
"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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13549269
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
 

Author Comment

by:perrosucio
ID: 13558188
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
Don't Cry: How Liquid Web is Ensuring Security

WannaCry is just the start. Read how Liquid Web is protecting itself and its customers against new threats.

 
LVL 9

Expert Comment

by:AlanJDM
ID: 13558402
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13558434
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
 

Author Comment

by:perrosucio
ID: 13559242
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
 

Author Comment

by:perrosucio
ID: 13559271
I just sent it again. The subject says FROM Experts-Exchange.

Thank you very much

Andy
0
 

Author Comment

by:perrosucio
ID: 13559336
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13559543
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
 

Author Comment

by:perrosucio
ID: 13564165
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13564248
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
 

Author Comment

by:perrosucio
ID: 13566074
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
 
LVL 9

Accepted Solution

by:
AlanJDM earned 2000 total points
ID: 13566289
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
 

Author Comment

by:perrosucio
ID: 13566863
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13566913
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
 

Author Comment

by:perrosucio
ID: 13567218
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13567270
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
 

Author Comment

by:perrosucio
ID: 13574462
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
 

Author Comment

by:perrosucio
ID: 13577162
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13593836
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
 

Author Comment

by:perrosucio
ID: 13594214
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
 
LVL 9

Expert Comment

by:AlanJDM
ID: 13594280
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
 

Author Comment

by:perrosucio
ID: 13594909
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
 

Author Comment

by:perrosucio
ID: 13595025
I have solve the warnings, they were related to the headers, but now they are not present.

Andy
0
 

Author Comment

by:perrosucio
ID: 13605235
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
 

Author Comment

by:perrosucio
ID: 13728114
Done, everything is working fine.

Thanks for all your help.

Andy
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Foreword (July, 2015) Since I first wrote this article, years ago, a great many more people have begun using the internet.  They are coming online from every part of the globe, learning, reading, shopping and spending money at an ever-increasing ra…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question