473,386 Members | 1,779 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

PHP excel output with graphic(.jpg, etc)?

123 100+
I use below to output data to a excel file using PHP,
however, how to include some photo(.jpg) in my excel output?


Expand|Select|Wrap|Line Numbers
  1. header("Content-type: application/vnd.ms-excel");
  2. header("Content-Disposition: attachment; filename=excel.xls");
Mar 3 '10 #1
7 6815
Atli
5,058 Expert 4TB
Hey.

How do you create the Excel file?
Mar 3 '10 #2
perhapscwk
123 100+
html output......the basic method
Mar 3 '10 #3
Atli
5,058 Expert 4TB
If you want me to be able to help you modify the output your are sending as your Excel file, I need to actually see the way you are currently creating the output. The code that needs to be modified.

Simply naming the method used to create pretty much every webpage in existence is not exactly helpful.
Mar 3 '10 #4
perhapscwk
123 100+
Expand|Select|Wrap|Line Numbers
  1.     header("Content-Type: application/vnd.ms-excel; charset=utf-8");
  2.     header("Content-Disposition: attachment; filename=zzzzz.xls");
  3.     header("Pragme: no-cache");
  4.     header("Expires: 0");    
  5.  
  6. print "<table border='0' cellspacing='5'>";
  7. print "<tr><th>Col A</th><th>Col B</th></tr>";
  8. print "<tr><td><img src="/images/aaaa.jpg"></td><td>Pictures</td></tr>";
  9. print "</table>";
However, when we open the xls, it is not open in same folder of the jpg file,
we can;t see the image.
Mar 4 '10 #5
Atli
5,058 Expert 4TB
Ok. Try embedding the image in the HTML tag.
Expand|Select|Wrap|Line Numbers
  1. $data = base64_encode(file_get_contents('image.png'));
  2. $imgTag = '<img src="data:image/png;base64,'. $data . '">';
  3.  
Mar 4 '10 #6
perhapscwk
123 100+
not works...i read from online ppl said img not the correct method to embed images in excel..any others suggestion?
Aug 4 '10 #7
Atli
5,058 Expert 4TB
I'm not sure exactly how Excel works, but you could try something like PHPExcel. That should allow you to build Excel sheets with embed images.
Aug 4 '10 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Phil Powell | last post by:
Based on the information I read in www.php.net on the header command I wrote a dummy test script to try to convert the contents of $stuff to MS Word downloadable format: ...
3
by: Whoever | last post by:
To create Excel file, you can Add Reference Visual Studio.NET, browse to ... and then select Microsoft.Office.Interop.Excel, etc. It endsup some reference to GUID in project file. You can then...
7
by: soubhagya | last post by:
hi.. I need to open an excel file and read particular rows column data from particular worksheet and write to another excel file. this is to be done with "C" program..Right now I have no...
2
by: Mustufa Baig | last post by:
Hi everybody, I have an ASP.NET website where clients can view their monthly billings by selecting different options. One of the option is the way they want to see the report i.e. whether they...
9
by: Anthony | last post by:
To me, creating Excel 2003 spreadsheets programmatically via VB.NET hasn't really changed since the days of VB6. That is, I'd do something similar to this Code: Dim ExcelApp As...
3
by: nome | last post by:
Hello Hoping someone can help explain the following behaviour. I have an application that does a series of redirects before hitting in a login page. If I insert this application hyperlink to...
16
by: Doogie | last post by:
Is there a way to export data from a control into excel if the control is not server side? Do I have to do it with java script or can I do it inside my VB.NET code?
2
by: anilkumarup | last post by:
Code-- objExcel = New Excel.Application Error/Exception-- I have included all the apis microsoft.office.interop.excel etc in bin but it is not able to make object of excel class.
8
by: K Viltersten | last post by:
I understand that the new versions of MS Word, MS Excel etc. allow for creation of a document using XML tags (the technique or format is called OOXML, i think). I imagine that the idea behind...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.