searls03 Posted April 21, 2011 Share Posted April 21, 2011 Does anyone how to make those little buttons where you can have the option of downloading a table on a website to a pdf or excel document? does anyone know what I am talking about? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/ Share on other sites More sharing options...
searls03 Posted April 22, 2011 Author Share Posted April 22, 2011 anyone know what I am talking about???????? :confused: :confused: Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1204843 Share on other sites More sharing options...
silkfire Posted April 22, 2011 Share Posted April 22, 2011 You'll need to write a script that implements an Excel class and then writes the values in a loop. Depends what format you want, too - XLS or the newer XLSX. Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1204901 Share on other sites More sharing options...
searls03 Posted April 22, 2011 Author Share Posted April 22, 2011 ok, do you have a website to help me with that? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1204938 Share on other sites More sharing options...
searls03 Posted April 29, 2011 Author Share Posted April 29, 2011 any thing to help me get started? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1208280 Share on other sites More sharing options...
mikosiko Posted April 29, 2011 Share Posted April 29, 2011 one option: http://www.phpclasses.org/search.html?words=excel&x=0&y=0&go_search=1 and here are many more Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1208284 Share on other sites More sharing options...
searls03 Posted April 29, 2011 Author Share Posted April 29, 2011 was giving me a link to google a joke or what? (by the way, I have tried to search, but can't seem to find a related topic.) Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1208287 Share on other sites More sharing options...
mikosiko Posted April 29, 2011 Share Posted April 29, 2011 no it wasn't ... just referring you to a good source to find a lot of related topics... search for example: - php to excel export or - php to pdf and you will find hundred of examples/tools etc that will help you with your pursuit... hope that help Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1208294 Share on other sites More sharing options...
searls03 Posted April 29, 2011 Author Share Posted April 29, 2011 ok. thanks Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1208299 Share on other sites More sharing options...
searls03 Posted May 2, 2011 Author Share Posted May 2, 2011 ok, so I was trying this code and it said it was corrupt. I have no idea how this works. please help: <?php // Query Database $result=mysql_db_query($dbname,"select userid,name,email,phone,cell,address,city,state from members where userid='$userid'"); // Send Header header("Pragma: public"); header("Expires: 0"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Type: application/force-download"); header("Content-Type: application/octet-stream"); header("Content-Type: application/download");; header("Content-Disposition: attachment;filename=report.xls "); // à¹à¸¥à¹‰à¸§à¸™à¸µà¹ˆà¸à¹‡à¸Šà¸·à¹ˆà¸à¹"ฟล์ header("Content-Transfer-Encoding: binary "); // XLS Data Cell xlsBOF(); xlsWriteLabel(2,0,"Name : "); xlsWriteLabel(2,1,"$name"); xlsWriteLabel(3,0,"email : "); xlsWriteLabel(3,1,"$email"); xlsWriteLabel(4,0,"phone : "); xlsWriteLabel(4,1,"$phone"); $xlsRow = 7; while(list($name,$email,$phone)=mysql_fetch_row($result)) { ++$i; xlsWriteNumber($xlsRow,0,"$name"); xlsWriteNumber($xlsRow,1,"$email"); xlsWriteLabel($xlsRow,2,"$phone"); $xlsRow++; } xlsEOF(); exit(); ?> Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1209650 Share on other sites More sharing options...
searls03 Posted May 3, 2011 Author Share Posted May 3, 2011 help!? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1210103 Share on other sites More sharing options...
searls03 Posted May 17, 2011 Author Share Posted May 17, 2011 anything? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1216315 Share on other sites More sharing options...
guyfromfl Posted May 17, 2011 Share Posted May 17, 2011 I have a class, but its rather large... but it works nice! idk how to send it to you Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1216647 Share on other sites More sharing options...
searls03 Posted May 17, 2011 Author Share Posted May 17, 2011 I have a class, but its rather large... but it works nice! idk how to send it to you what do you mean you have a class? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1216650 Share on other sites More sharing options...
guyfromfl Posted May 17, 2011 Share Posted May 17, 2011 http://php.net/manual/en/language.oop5.basic.php Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1216654 Share on other sites More sharing options...
searls03 Posted May 17, 2011 Author Share Posted May 17, 2011 if you need to send it, you could post it in pieces or send a pm with it in pieces to me. Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1216656 Share on other sites More sharing options...
searls03 Posted May 17, 2011 Author Share Posted May 17, 2011 or make a document and upload it..... Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1216664 Share on other sites More sharing options...
silkfire Posted May 18, 2011 Share Posted May 18, 2011 boy, you're persistent Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1216868 Share on other sites More sharing options...
searls03 Posted May 19, 2011 Author Share Posted May 19, 2011 That's mainly because I am so close to being done!!!! Any help? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1217784 Share on other sites More sharing options...
searls03 Posted June 6, 2011 Author Share Posted June 6, 2011 Anybody help me at all?????? :confused: :confused: Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1225681 Share on other sites More sharing options...
xyph Posted June 6, 2011 Share Posted June 6, 2011 Have you tried http://www.phpclasses.org/package/3187-PHP-Read-and-write-data-to-Excel-XML-worksheets.html I've used it before with success. Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1225686 Share on other sites More sharing options...
searls03 Posted June 6, 2011 Author Share Posted June 6, 2011 it wouldn't work, anything else? Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1225692 Share on other sites More sharing options...
xyph Posted June 6, 2011 Share Posted June 6, 2011 No, because it's something you're doing wrong. No amount of functions or classes will fix this. Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1225695 Share on other sites More sharing options...
searls03 Posted June 6, 2011 Author Share Posted June 6, 2011 ok, lets see, I am trying the code a bit, but it keeps saying unreadable. so basically I want to have lets say A1 say name and all the rest of the A's be all the names pulled from the database. lets say B's are email addresses, C's are phone numbers. Could you help me with the code as to what is what seeing as there was no documentation with it? here is what I have tried, but keep getting errors <?php session_start(); // Must start session first thing /* Created By Adam Khoury @ [url='http://www.flashbuilding.com/']www.flashbuilding.com[/url] -----------------------June 20, 2008----------------------- */ // Here we run a login check ini_set("session.gc_maxlifetime", "900000000000000000000000"); if (!isset($_SESSION['id'])) { echo 'Please <a href="/login.php">log in</a> to access your account'; exit(); } //Connect to the database through our include include_once "connect_to_mysql.php"; // Place Session variable 'id' into local variable $userid = $_SESSION['id']; // Process the form if it is submitted $sql = mysql_query("SELECT * FROM members WHERE userid='$userid'"); while($row = mysql_fetch_array($sql)){ $name = $row["name"]; $phone = $row["phone"]; $username = $row["username"]; $address = $row["address"]; $city = $row["city"]; $state = $row["state"]; $zip = $row["zip"]; $cell = $row["cell"]; $email = $row["email"]; $accounttype = $row["accounttype"]; $rank = $row["rank"]; $badges = $row["badges"]; } include "ExcelXMLParser.php"; $ExcelXMLParser = new ExcelXMLParser(); $result = $ExcelXMLParser->openWorkbook("sample.xml",array()); $StartWork = array("D3"=>"$name","D9"=>"$name","D10"=>"$name","D11"=>"$name","D12"=>"$name","D13"=>"$name","D14"=>"$name"); $TimeOutLunch = array("E8"=>"12:00 PM","E9"=>"11:59 AM","E10"=>"12:01 PM","E11"=>"11:00 AM","E12"=>"01:00 PM","E13"=>"01:30 PM","E14"=>"02:00 PM"); $TimeInLunch = array("F8"=>"12:30 PM","F9"=>"01:00 PM","F10"=>"01:01 PM","F11"=>"02:00 PM","F12"=>"02:15 PM","F13"=>"01:54 PM","F14"=>"02:40 PM"); $EndWork = array("G8"=>"06:00 PM","G9"=>"07:32 PM","G10"=>"05:30 PM","G11"=>"06:54 PM","G12"=>"04:30 PM","G13"=>"06:12 PM","G14"=>"06:01 PM"); if(!ExcelXMLError::isError($result)){ /* get the document properties for this excel files */ $Author = $ExcelXMLParser->Workbook->Document->getProperty("Author"); $LastAuthor = $ExcelXMLParser->Workbook->Document->getProperty("LastAuthor"); $Created = $ExcelXMLParser->Workbook->Document->getProperty("Created"); $Company = $ExcelXMLParser->Workbook->Document->getProperty("Company"); $Version = $ExcelXMLParser->Workbook->Document->getProperty("Version"); $ExcelXMLParser->Workbook->setActiveSheet(0); $ExcelXMLParser->Workbook->setFirstVisibleSheet(0); /* set a particular cell value */ $Ws =& $ExcelXMLParser->Workbook->getWorksheetByName("1-26-2003"); $Cl =& $Ws->Table->getCellByAddress("D3"); $Cl->setValue("Andrew Aculana"); /* lets traverse our workbook, starting from the first worksheet */ $Worksheet =& $ExcelXMLParser->Workbook->getFirstWorksheet(); while($Worksheet){ $Row =& $Worksheet->Table->getFirstRow(); while($Row){ $Cell =& $Row->getFirstCell(); while($Cell){ $CellAddress = $Cell->getCellAddress(); if(in_array($CellAddress,array_keys($StartWork))){ $Cell->setValue($StartWork[$CellAddress]); } if(in_array($CellAddress,array_keys($TimeOutLunch))){ $Cell->setValue($TimeOutLunch[$CellAddress]); } if(in_array($CellAddress,array_keys($TimeInLunch))){ $Cell->setValue($TimeInLunch[$CellAddress]); } if(in_array($CellAddress,array_keys($EndWork))){ $Cell->setValue($EndWork[$CellAddress]); } $Cell =& $Row->getNextCell(); } $Row =& $Worksheet->Table->getNextRow(); } $Worksheet =& $ExcelXMLParser->Workbook->getNextWorksheet(); } $result = $ExcelXMLParser->SaveWorkbook("sample.xls",true); if(ExcelXMLError::isError($result)){ $result->raiseError(); } }else{ $result->raiseError(); die('x'); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1225701 Share on other sites More sharing options...
searls03 Posted June 6, 2011 Author Share Posted June 6, 2011 oh yeah, nothing needs to add up or anything either. Quote Link to comment https://forums.phpfreaks.com/topic/234342-table-download-for-excel/#findComment-1225702 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.