PHP - Moved: Excel Csv
This topic has been moved to Miscellaneous.
http://www.phpfreaks.com/forums/index.php?topic=345846.0 Similar TutorialsThis topic has been moved to Other. http://www.phpfreaks.com/forums/index.php?topic=316401.0 This topic has been moved to MySQL Help. http://www.phpfreaks.com/forums/index.php?topic=330652.0 I need some help and hopefully will respond. I'm trying to put some information to the second row of the excel sheet once extracted. Can somebody help me with this script? I'm trying to move the address line to the second row. Thanks. Hello, i am currently getting an Microsoft Excel formatted text file whose save type is .Txt from a URL.I used to open it and will change the save type as excel file. Please suggest whether we can do this with php code. currently my code is like this, <? php copy("http://www.faa.gov/airports/airport_safety/airportdata_5010/menu/emergencyplanexport.cfm?Region=&District=&State=&County=&City=LAS%20VEGAS&Use=&Certification=","./contactsexport.xls"); ?> where as the contactsexport.xls type is .Txt which i need it in .xls Thanks in Advance. Hi I have a database set up using MySQL and want to be able to query this and then export to Excel using PHP. I've had a look around on the web but a lot of what I'm reading is going over my head. I don't have PEAR so can't use the ready made stuff. Basically, I want to be able to query the database, then export the arrays to an excel file and a pop up to appear asking the user to open / save / cancel (standard pop-up) Anyone know of any good places to start looking for the information for this? Sorry, I'm new to all this so any help / pointers would be greatly appreciated. Cheers I need a way of parsing Excel files.. both xls and xlsx in what seems to be various formats.. the concept of the way the expected sheets are to come in is with 2 tabs first tab row one column one will be a single value.. second tab will be any number of values only 2 columns though. I had found one parser class that I could use but it was very limiting and for some reason didn't work when I saved a fresh file... whats the best class, or way of handling an excel file? is there anything out there freely avaliable to work with thats kept upto date? or that works? Hi I have a script which references a DB and then produces an XML output saved as XLS to then open in Excel. This works an absolute dream in my dev environment using IE7 and in live using Firefox. However my entire audience uses IE7 and this is where it breaks in the live environment. For some reason, I cannot get the download to work. I get a windows pop-up with an error on it - see attached. If you need to see code, let me know which bit of code could possibly cause this, i.e. headers etc. I've not posted code as there's loads of it and I can't understand why it works in dev in IE 7 but not in live, and works in Firefox in live. I need to parse xls files (Microsoft Excel). The option to tell the users who will be uploading the files to convert it to a more friendly format like XML or CSV is not an option (I know its unfortunately, though I have to make it so it parses those formats as well (fun is)). Users must be able to just save the file, and upload it as is. below is a link to a example xls file. So I am looking to see if there's anything native to php that will allow me to open and read xls formatted files quickly and efficiently and work with the values independently on a per row per column basis when outputting them. Or if there's a recommended library/class I can use that someone here can suggest. My biggest issue is I am on a time crunch so I need something I can work with quickly and efficiently all around. Any samples would be greatly appreciated. http://mtpdev.com/dev/xls-reader/sample.xls Hi All, I am trying to export a table into excel and it is working, kind of.. I'm trying to import data that has commas in it. Unfortunately, it looks like this "PHP to CVS" process is comma delimited. How can I get around that, while having the data in the correct columns? Here is my code: Code: [Select] $file = 'Notes_Export'; $csv_output = ''; $sql = "SHOW COLUMNS FROM prop_notes WHERE Field IN ('note', 'created_by', 'created_on', 'updated_by', 'updated_on')"; $result = mysqli_query($connect, $sql); $i = 0; if (mysqli_num_rows($result) > 0) { while ($row = mysqli_fetch_assoc($result)) { $csv_output .= $row['Field'].", "; $i++; } } $csv_output .= "\n"; $sql = "SELECT note, created_by, created_on, updated_by, updated_on FROM prop_notes"; $values = mysqli_query($connect, $sql); while($rowr = mysqli_fetch_row($values)) { for ($j=0;$j<$i;$j++) { $csv_output .= $rowr[$j].", "; } $csv_output .= "\n"; } $filename = $file."_".date("Y-m-d_H-i",time()); header("Content-type: application/vnd.ms-excel"); header("Content-disposition: csv" . date("Y-m-d") . ".csv"); // header( "Content-disposition: filename=".$filename.".csv"); header("Content-disposition: attachment; filename=".$filename.".csv"); print $csv_output; exit; Hi people. Need some help if anyone could give a hand! I'm currently trying to incorporate an export to Excel feature on search returns on my web page. Here is how my searches are returned, so what I want now is when the user clicks on the 'Export to Excel' button it downloads the search results and opens it in the same format in Excel. I've tried using http://phpexcel.codeplex.com/ but can't understand how to use it properly, does anyone have any suggestions? I don't have any code written for the Export to Excel yet as it's just a submit button. How I see it in my head is the user clicks the button, it goes to a new page and performs a new query then downloads that but I don't no if thats right or not. Hi, I am attempting to export some table data to an excel spreadsheet. Below is the code I am working with. <?php include('includes/admin_session.php'); require_once("includes/connection.php"); function cleanData(&$str) { $str = preg_replace("/\t/", "\\t", $str); $str = preg_replace("/\r?\n/", "\\n", $str); if(strstr($str, '"')) $str = '"' . str_replace('"', '""', $str) . '"'; } // file name for download $filename = "student_list_" . date('Ymd') . ".xls"; header("Content-Disposition: attachment; filename=\"$filename\""); header("Content-Type: application/vnd.ms-excel"); $flag = false; $result = mysqli_query($connection,"SELECT * FROM students ORDER BY tutor") or die(mysqli_error($connection)); while(false !== ($row = mysqli_fetch_assoc($result))) { if(!$flag) { // display field/column names as first row echo implode("\t", array_keys($row)) . "\n"; $flag = true; } array_walk($row, 'cleanData'); echo implode("\t", array_values($row)) . "\n"; } ?> It is exporting the rows as requested and I am able to open the file in excel....however...when downloading it becomes stuck on a loop and continues to download over 20mb of nothing. As a result I am forced to stop the download. When I open my excel file, below my table data is the following error, over and over and over and over! Quote <br /> <b>Warning</b>: array_walk() [<a href='function.array-walk'>function.array-walk</a>]: The argument should be an array in <b>/home/inschool/public_html/student_list_export.php</b> on line <b>33</b><br /> <br /> <b>Warning</b>: array_values() [<a href='function.array-values'>function.array-values</a>]: The argument should be an array in <b>/home/inschool/public_html/student_list_export.php</b> on line <b>34</b><br /> <br /> <b>Warning</b>: implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in <b>/home/inschool/public_html/student_list_export.php</b> on line <b>34</b><br /> Any help on this would be awesome ok, so I am not good with arrays, they confuse me. how can I set this up so that $data is all results that are returned from the database that correspond to it? Code: [Select] $data = array( array("firstname" => '$firstname', "lastname" => '$lastname', "age" => '$age')); the original code looked like: Code: [Select] <?PHP $data = array( array("firstname" => "Mary", "lastname" => "Johnson", "age" => 25), array("firstname" => "Amanda", "lastname" => "Miller", "age" => 18), array("firstname" => "James", "lastname" => "Brown", "age" => 31), array("firstname" => "Patricia", "lastname" => "Williams", "age" => 7), array("firstname" => "Michael", "lastname" => "Davis", "age" => 43), array("firstname" => "Sarah", "lastname" => "Miller", "age" => 24), array("firstname" => "Patrick", "lastname" => "Miller", "age" => 27) ); ?> but that won't do it for me. I need it so that the results from the database will automatically be filled in. basically, everyone that is in the database, so when a new member is added, they will show up too. please help I have an excel file with many rows and columns but depending on the user I need it to show only one row. I am a php newbie. Is it possible to export a single value from a mysql DB into a pre-existing excel spread sheet? I know how to create a spread sheet from php and mysql, but not a single value into a pre-existing excel document cell. here's basically what I'm doing: Creating a financial expense tracking report in php, user will input each expense, it will keep a running tally of the available funds in user's bank account. The user has an excel spread sheet that requires the current value of available funds and updates a budget forecast according. SO, I need to somehow get the available balance of the bank account (generated by user input) into the pre-existing excel spreadsheet. Any thoughts? I'm totally at a loss. Thanks! Hi I have a page displaying orders from a mysql table. How can i add a button which exports this to an excel file? Hi Attached file I get sent a excel file as attached each day updating products and stock levels and prices.. I am trying to find away to dump that file into my database without having to restructure the excel file. It needs to be in the data base in such away that I can create a popout menu with the headings you see in the file i.e CPUs :: Intel CPUs :: AMD etc etc to filter the procucts in my shopping cart.. I have 3 tables atm, maincat, subcat and products.. But it takes way to long to try and manually sort the changes. Any Ideas on how I can do it by just dumping the excel file? Hi. I have a large amount of data in an excel spread sheet. I have isolated 3 rows containing a date (yyyy-mm-dd plus two decimal values). I saved this as a tab delimited text instead of a comma separated csv. What I want to do is read each line of a text file and split it up into 3 and construct an INSERT INTO sql. the problem is this is not separated by comas for a split function. Can I split on a tab instead? I have used commas in the past only. TIA Desmond.
The idea: an authorized web user (novice) uploads an Excel spreadsheet via FTP to a website. The spreadsheet contains 9 rows and 5 columns, which will look something like this: 12345 | sky | blue | sunny | happy | ------------------------------------------- 54321 | water | green | cold | sad | ------------------------------------------- etc ... The script I'm looking for would show the first 3 of the 9 rows at the same time and rotate to the next 3 on refresh and so on. The output of the script would look something like this: <div><p><a href="http://www.xyz.com/12345.html>;<img src="http://www.xyz.com/12345.jpg" /></a><br /> <strong>sky</strong><br />blue<br />sunny<br />happy</p><br /> <p><a href="http://www.xyz.com/12345.html">Details</a></p></div><br /> <div><p><a href="http://www.xyz.com/54321.html>;<img src="http://www.xyz.com/54321.jpg" /></a><br /> <strong>water</strong><br />green<br />cold<br />sad</p><br /> <p><a href="http://www.xyz.com/54321.html">Details</a></p></div> etc... the script structure would always be the same but the values of each div would change based on the row values of the spreadsheet. Can this be done? Can anyone tell me the best tools to read Excel files? hi all is there anyway embedding excel or .csv files to the webpage other than the folowing two options . saving it as a webpage . using google docs i used the following code, iam getting the .csv file in the page, but it would be good to have the color formatting, bold, italics... also in the webpage. is it possible? Code: [Select] <?php $cnx = fopen("example.csv", "r"); //open example.csv echo("<table style='border:1px solid #ddd;'>"); // echo the table while (!feof ($cnx)) { // while not end of file $buffer = fgets($cnx); // get contents of file (name) as variable $values = explode(",", $buffer); //explode "," between the values within the contents echo "<tr>"; for ( $j = 0; $j < count($values); $j++ ) { // echo("<td style='border:1px solid #ddd;'>$values[$j]</td>"); } echo"</tr>"; }; echo("</table>"); fclose($cnx); //close filename variable ?> |