IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Langage PHP Discussion :

Export des données en utilisant des signets


Sujet :

Langage PHP

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Nouveau candidat au Club
    Femme Profil pro
    Étudiant
    Inscrit en
    Mars 2015
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Femme
    Localisation : Tunisie

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Mars 2015
    Messages : 1
    Par défaut Export des données en utilisant des signets
    Bonjour, je suis débutante sur phpexcel mais j'ai réussi à développer un module qui permet d'exporter les données depuis la base dans un fichier excel en faisant la correspondance entre des signets et des champs de la bd. Mais là, il me demande de faire la même chose mais avoir plusieurs signets pour un seul champs. Le point en commun c'est que les signets commence par les même caractère exemple: Client, Client1, Client2 ...
    Votre expérience fera mon bonheur .. A vos claviers
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
     
    <?php
     
    require_once $Ini->path_third . '/phpexcel/PHPExcel.php';
    require_once $Ini->path_third . '/phpexcel/PHPExcel/Writer/Excel2007.php';
     
    private $oWorkbook;
    private $oWorksheet;
    private $oCell;
    private $oRs;
     
     
    /* This structure encodes the difference between ISO-8859-1 and Windows-1252,
       as a map from the UTF-8 encoding of some ISO-8859-1 control characters to
       the UTF-8 encoding of the non-control characters that Windows-1252 places
       at the equivalent code points. */
     
    function cp1252_to_utf8($str) {
    	var_dump($str);
    	var_dump(iconv_get_encoding('all'));
    	return $str;
    }
     
     
    //------------------------------------------------------------------
    // @function ax_GetDbRs
    // @purpose Get the SQL recordset according to the input request
    //------------------------------------------------------------------
     
    function ax_OpenWkb($filename) {
    	$oReader = PHPExcel_IOFactory::createReader('Excel2007');
    	$this->oWorkbook = $oReader->load($filename);	
    }
     
    function ax_CloseWkb($filename) {
    	$objWriter = PHPExcel_IOFactory::createWriter($this->oWorkbook, 'Excel2007');
    	$objWriter->save($filename);
    }
     
     
    function ax_UploadWkb($filename,$forcetext=false) {
     
    	$objWriter = PHPExcel_IOFactory::createWriter($this->oWorkbook, 'Excel5');
    	ob_end_clean();
    	if(!$forcetext) {
    		header('Content-type: application/vnd.ms-excel');		
    		header('Content-Disposition: attachment;filename="'.$filename.'.xls"');
        } else {
    		header('Content-type: plain/text');	
    		header('Content-Disposition: attachment;filename="'.$filename.'.txt"');
    	}
    	header('Cache-Control: max-age=0');
    	$objWriter->save('php://output');
    	ob_end_flush();
    	ob_start();
    }
     
     
    function ax_SetRecordset($request)  { 
    	sc_select(dataset, $request);
    	$this->oRs = $dataset;
    }
     
    function ax_SyncNamedRange()  { 
    	if (false == $this->oRs) {
    		ax_DebugPush('Error while accessing dataset.');
    	} else {
    		foreach ($this->oWorkbook->getNamedRanges() as $oNames => $oNamedRange) {
            	$sName = $oNamedRange->getName();
    			$this->oWorksheet = $oNamedRange->getWorksheet();
    	        $this->oCell = $this->oWorksheet->GetCell($oNamedRange->GetRange());
            	for ($i = 0; $i < $this->oRs->FieldCount(); $i++) {
                	$fld = $this->oRs->FetchField($i);
                	if (strtolower($fld->name) == strtolower($sName)) {
    	                $this->oCell->setValue($this->oRs->fields[$i]);
    					ax_DebugVar($sName,$this->oCell->getValue());
                	}
            	}
        	}	
     
    	}	
    }
     
    function ax_SyncWorksheet($sheetname)  { 
    	if (false == $this->oRs) {
    		ax_DebugPush('Error while accessing dataset.');
    	} else {
    		$rows    = $this->oRs->rowCount();
    		$rows    = 2;
    		$columns = $this->oRs->fieldCount();
    		$columns = 10;
    		$this->oWorksheet = $this->oWorkbook->getActiveSheet();
     
    		$rowOffset = 1;
    		$colOffset = 1;
    		$this->oWorksheet->setCellValueByColumnAndRow(0, 1, $rows);
    		$this->oWorksheet->setCellValueByColumnAndRow(0, 2, $columns);
     
    		for ($colIndex=0;$colIndex<$columns;$colIndex++)
         	{
    			$fieldInfo = $this->oRs->fetchField($colIndex);
    			$this->oWorksheet->setCellValueByColumnAndRow($colIndex +$colOffset, $rowOffset, $fieldInfo->name);	
    		}	
    		$this->oRs->MoveFirst();		
    		$arr = $this->oRs->FetchRow();
    		$this->oWorksheet->setCellValueByColumnAndRow(0, 3, count($arr));
    		$rowOffset = 3;
    		for ($rowIndex=0;$rowIndex<$rows;$rowIndex++) {
    			$this->oWorksheet->fromArray($this->oRs->FetchRow(), NULL, 'B'.($rowIndex+$rowOffset));
    			for ($colIndex=0;$colIndex<$columns;$colIndex++)
         		{
    				$this->oWorksheet->setCellValueByColumnAndRow($colIndex +$colOffset, $rowIndex+$rowOffset, $this->oRs->fields[$colIndex]);	
    			}	
     
    			$this->oRs->MoveNext();
    		}
    	}
    }
     
    ?>

  2. #2
    Expert confirmé
    Avatar de mathieu
    Profil pro
    Inscrit en
    Juin 2003
    Messages
    10 699
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations forums :
    Inscription : Juin 2003
    Messages : 10 699
    Par défaut
    Je n'ai pas compris ce que vous appelez un signet ?

Discussions similaires

  1. Réponses: 10
    Dernier message: 11/05/2014, 15h19
  2. Affichage des données en utilisant des Grids
    Par danoi18 dans le forum C#
    Réponses: 0
    Dernier message: 11/01/2013, 17h29
  3. Des chercheurs utilisent des bactéries pour stocker des données
    Par Katleen Erna dans le forum Actualités
    Réponses: 45
    Dernier message: 19/01/2011, 03h37
  4. Réponses: 6
    Dernier message: 13/12/2010, 20h20
  5. Réponses: 2
    Dernier message: 06/06/2010, 15h15

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo