Jump to content

Recommended Posts

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();

?>

  • 2 weeks later...
  • 3 weeks later...

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');
}

?>

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.