Search the web
Sign In
New User? Sign Up
phpKeralaUg · PHP Users Group : Kerala
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want your group to be featured on the Yahoo! Groups website? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Speed up excel export   Message List  
Reply | Forward Message #390 of 409 |
Hi friends,

Iam trying to export the datas from mysql to excel file with different color for
different columns. All are working if the datas are low (about 2000), but i need
to export about 8000 records from the mysql. when i try to take this mcuh record
i need to wait abt 5 minutes. How can i speed up this process,
Iam pasting my code here. Please give an advice.



<?php
include ('config.php');
$select = "SELECT Tariff, Service, DeliveryDate, DeliveryTime, POD FROM pod
order by Date asc";   
$export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) );
$fields = mysql_num_fields ( $export );

$row =0;

require_once "class.writeexcel_workbook.inc.php";
require_once "class.writeexcel_worksheet.inc.php";
$fname = tempnam("/tmp", "panes.xls");
$workbook = &new writeexcel_workbook($fname);
$worksheet1 =& $workbook->addworksheet('Panes 1');

    for ( $i = 1; $i < $fields; $i++ ){   
        $headerfieldname = mysql_field_name( $export , $i );
          $worksheet1->write(0, $i, $headerfieldname, '');
    }
   
    $cnt =1;
       
    $format1 =& $workbook->addformat(array('fg_color' =>'rose'));
    $format2 =& $workbook->addformat(array('fg_color' =>'yellow'));
    $format3 =& $workbook->addformat(array('fg_color' =>'purple'));
     $format4 =& $workbook->addformat(array('fg_color' =>'white'));           

    while( $row = mysql_fetch_row( $export ) )  {  

        $selectcolor = "SELECT colorname, col FROM colorscheme where
row='".$cnt."' order by col";
       
        $exportcolor = mysql_query ( $selectcolor );
        $newcolors = mysql_fetch_object($exportcolor);
        $column  = $newcolors->col;
       
        for($q=1; $q <=14; $q++)  {           
       
    
            switch($newcolors->colorname) {
                case 'rose' :
                    $format = $format1;
                    break;                   
                case 'yellow' :
                    $format = $format2;
                    break;
                case 'purple' :
                    $format = $format3;
                    break;                         
                default:
                    $format = $format4;
                    break;       
            }
           
            $newcolors = mysql_fetch_object($exportcolor);
            $column  = $newcolors->col;
           
         
            $worksheet1->write($cnt, $q, $row[$q], $format );   
               
        }               
        $cnt++;   
    
           
    }
   
    $workbook->close();
    header("Content-Type: application/x-msexcel; name=\"".'Log-'.date('dmy',
time()).".xls\"");
    header("Content-Disposition: inline; filename=\"".'Log-'.date('dmy',
time()).".xls\"");
    $fh=fopen($fname, "rb");
    fpassthru($fh);
    unlink($fname);   

With Regards
Binoy.M.V



Looking for local information? Find it on Yahoo! Local
http://in.local.yahoo.com/

[Non-text portions of this message have been removed]




Mon Jul 13, 2009 6:09 pm

binoymvee
Offline Offline
Send Email Send Email

Forward
Message #390 of 409 |
Expand Messages Author Sort by Date

Hi friends, Iam trying to export the datas from mysql to excel file with different color for different columns. All are working if the datas are low (about...
binoy
binoymvee
Offline Send Email
Jul 13, 2009
6:09 pm

If you want to write an xls with only one sheet, as it seems from your code, then try this way. just print your whole things on a web page, using colors you...
Prasad C
prasadc_nair
Offline Send Email
Jul 14, 2009
10:45 am

Thanks Prasad , I did it like you said to me, its working . header i set as $filename = 'Log-'.date('dmy', time()).'.xls'; header('Content-type:...
binoy
binoymvee
Offline Send Email
Jul 15, 2009
2:17 pm

Dear all  I am registering a cookie as setcookie("user", $namV, time()+1200); And I'm checking the cookie exired or not as : if (!isset($_COOKIE["user"])) ...
Shajan Joseph
shajan4
Offline Send Email
Sep 22, 2009
9:44 am

I don't know, but its working fine with IE7, you might have some new features of IE8 that prevent it from storing cookies. check protected mode in IE, if you...
Prasad C
prasadc_nair
Offline Send Email
Sep 22, 2009
4:07 pm

Thank u Prasad for yr reply. This I noticed in other browser (IE). that was i think 7.6. In old version it was working.  In my coding after seeing from google...
Shajan Joseph
shajan4
Offline Send Email
Sep 23, 2009
5:08 am

 Can you please help me how to do the video streaming through php coding. I'm having videos of format .VOB. Thanks, Shajan Joseph [Non-text portions of this...
Shajan Joseph
shajan4
Offline Send Email
Sep 24, 2009
9:49 am

If not possible with php coding, any javascript etc like oneMy platform is RHEL linux. thanks, shajan ... From: Shajan Joseph <shajan4@...> To:...
Shajan Joseph
shajan4
Offline Send Email
Sep 25, 2009
6:25 am

Shajan,   As far as I know you need to have Adobe Flash Media Server or RED Server to stream .VOB files.   Best Regards Praveen ... From: Shajan Joseph...
Praveen V
ninethsense
Offline Send Email
Sep 25, 2009
8:37 am

Hi , You need ffmpeg in linux for streaming videos and audios . You can get many opensource scripts that can do the remaining work . Just need to give the path...
Hari KT
kthari85
Offline Send Email
Sep 25, 2009
8:37 am

You can check my friend's site http://prabhanjan-panigrahi.blogspot.com/2007/05/building-video-sharing-site.html Regards, Aji Issac, Founder,...
Aji Issac
ajiissac1
Offline Send Email
Sep 25, 2009
9:22 am

Thank you Aji, Praveen & Hari. I will try and let you know the status. Shajan ________________________________ From: Aji Issac <ajiissac@...> To:...
Shajan Joseph
shajan4
Offline Send Email
Sep 25, 2009
11:11 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help