matfish Posted January 26, 2007 Share Posted January 26, 2007 In regards to : [url=http://www.phpfreaks.com/forums/index.php/topic,89428.0.html]http://www.phpfreaks.com/forums/index.php/topic,89428.0.html[/url]Im also looking for the same.Can anyone point me in the right right direction to do the following:-Iv got an excel spreadsheet on the server complete with heading/logo & footer.I need to read it, add a new line of values and then export/upload back to the server.Iv got the reading/writing of values without a problem, however How do I maintain the header/footer and logo etc? Any just put in the new line/entry?Many thanks Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/ Share on other sites More sharing options...
Psycho Posted January 26, 2007 Share Posted January 26, 2007 Are you needing to change the header/footer? If not, I'm not sure I understand the problem. Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/#findComment-169827 Share on other sites More sharing options...
matfish Posted January 26, 2007 Author Share Posted January 26, 2007 Hi, I already have an original document with a company logo at the top. The footer sum up the values which I need to add/import.Therefore I want to keep the header/footer the same and just update the values within the table?Thanks Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/#findComment-170187 Share on other sites More sharing options...
Psycho Posted January 27, 2007 Share Posted January 27, 2007 Well, you say you already can read/write data to the file already. I see no reason why doing so would change the header/footer - which in your original statement you said you wanted to keep the same. But, in your last statement you say that the footer includes a sum of th evalues in the table.So, I am still a little confused here. Are you having problems with the header/footer getting changed when you edit data in the spreadsheet OR is the problem that you need to change the footer to show a new sum? Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/#findComment-170320 Share on other sites More sharing options...
matfish Posted January 29, 2007 Author Share Posted January 29, 2007 Lets try asking a different question...How do you open an existing excel file (which already has a company logo&heading) and then use the below to post my query to that excel doc to download?[code]$line1="RSR\tProduct\tColor\tSales\t";$line2="1\tPrinter\tGrey\t13\t";$line3="2\tCD\tBlue\t15\t";$line4="3\tDVD\tRed\t7\t";$line5="4\tMonitor\tGreen\t4\t";$line6="5\tTelephone\tBlack\t2\t";$data="$line1\n$line2\n$line3\n$line4\n$line5\n$line6\n";header("Content-type: application/x-msdownload");header("Content-Disposition: attachment; filename=extraction.xls");header("Pragma: no-cache");header("Expires: 0");print "$header\n$data";[/code]? Any ideas? Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/#findComment-171740 Share on other sites More sharing options...
Psycho Posted January 29, 2007 Share Posted January 29, 2007 Well, I found a tutorial on working with a spreadsheet: http://www.dreamincode.net/forums/showtopic10132.htmAnd, now I see your problem. At first I couldn't write to an existing spreadsheet. But, if I used PHP to first create a spreadsheet I could then open and write new data to the spreadsheet on successive sessions. I'm pretty sure this is because the spreadsheet created through PHP is tab delimited, whereas a "new" document created through Excel is in a proprietary Excel format.I then took the template I created through PHP and added a header and footer. But, then as soon as I edited the document through PHP it lost its headers. Because a tab delimited file is nothing more than a text document - does not have headers.So, I don't have a solution for you. but, I did find another source that may be of some interest. It shows how to create a spreadsheet with styles and formatting: http://www.tecnorama.org/document.php?id_doc=64Uless you can find a class or plug-in, I think you may be out of luck. If you were to open an Excel file that has a header/footer in a text editor you would see what a mess the code is and how difficult it could be to replicate.Good luck. Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/#findComment-171955 Share on other sites More sharing options...
matfish Posted January 30, 2007 Author Share Posted January 30, 2007 Many thanks for your reply. The examples in the links you have supplied are what I have been using anyway. Thanks again. Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/#findComment-172638 Share on other sites More sharing options...
Psycho Posted January 30, 2007 Share Posted January 30, 2007 Here is a class that may work for you: http://www.phpclasses.org/browse/package/86.html Link to comment https://forums.phpfreaks.com/topic/35802-php-importexport-excel/#findComment-172815 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.