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

jQuery Discussion :

Extraire fichier CSV en jqgrid


Sujet :

jQuery

Vue hybride

Message précédent Message précédent   Message suivant Message suivant
  1. #1
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2008
    Messages
    92
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Janvier 2008
    Messages : 92
    Par défaut Extraire fichier CSV en jqgrid
    Bonjour tout le monde,

    Je voudrai extraire un fichier CSV vers un page HTLM avec en Jquery ou Jqgrid pour faire des tris divers dans le page HTLM.
    Et pouvant faire des recherches sur tous les champs.

    Merci de votre aide !!
    Images attachées Images attachées  

  2. #2
    Rédacteur

    Avatar de danielhagnoul
    Homme Profil pro
    Étudiant perpétuel
    Inscrit en
    Février 2009
    Messages
    6 389
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 74
    Localisation : Belgique

    Informations professionnelles :
    Activité : Étudiant perpétuel
    Secteur : Enseignement

    Informations forums :
    Inscription : Février 2009
    Messages : 6 389
    Billets dans le blog
    125

    Blog

    Sans l'analyse et la conception, la programmation est l'art d'ajouter des bogues à un fichier texte vide.
    (Louis Srygley : Without requirements or design, programming is the art of adding bugs to an empty text file.)

  3. #3
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2008
    Messages
    92
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Janvier 2008
    Messages : 92
    Par défaut
    Bonjour tout le monde
    Merci Bernard pour ton lieu, mais j'ai trouvé que ça :
    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
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
     
    <html>
      <head>
        <meta HTTP-EQUIV="Content-Type" CONTENT="text/html;CHARSET=iso-8859-1">	
        <title>Test fichier CSV</title>
        <link rel="stylesheet" type="text/css" media="screen" href="css/jquery-ui-1.8.17/jquery-ui-1.8.17.custom.css" />
        <link rel="stylesheet" type="text/css" media="screen" href="css/ui.jqgrid.css" />
     
        <script type="text/javascript" src="https://www.google.com/jsapi"></script>    
        <script type="text/javascript">
    		google.load("jquery", "1");	
    		google.load("jqueryui", "1");	
        </script>
     
    	<script type="text/javascript" src="js/i18n/grid.locale-fr.js"></script>
    	<!--<script type="text/javascript" src="js/i18n/grid.locale-ja.js"></script>-->
        <script type="text/javascript" src="js/jquery.jqGrid.src.js" ></script>
        <!-- See http://code.google.com/p/jquerycsvtotable/ -->
        <script src="js/jquery.csvToTable.js" type="text/javascript"></script>
     
        <style type="text/css">
          html,
    	  body {
            margin: 0;
            padding: 0;
          }
     
          /* CSV Table Classes */
          TABLE.CSVTable {
            font: 0.8em Verdana,Arial,Geneva,Helvetica,sans-serif;
            border-collapse: collapse;
            width: 450px;
          }
     
          /* Header */
          TABLE.CSVTable THEAD TR {
            background: #E8EDFF;
          }
          TABLE.CSVTable TH {
            font-family: "Lucida Sans Unicode","Lucida Grande",Sans-Serif;
            font-size: 1.2em;
          }
     
          /* Table Cells */
          TABLE.CSVTable TD, TABLE.CSVTable TH {
            padding: 8px;
            text-align: left;
            border-bottom: 1px solid #FFFFFF;
            border-top: 1px solid transparent;
          }
          /* Default background color for rows */
          TABLE.CSVTable TR {
            background: #F0F0F0;
          }
          /* Background color for odd rows */
          TABLE.CSVTable TR.odd {
            background: #F9F9F9;
          }
          /* Hover color for all rows */
          TABLE.CSVTable TR:hover {
            background: #E8EDFF;
          }
     
        </style>
     
        <script type="text/javascript">
          $(function() { 
            "use strict";
     
            jQuery.get('data.csv', function(data) {
              $('#CSVSource').html('<pre>' + data + '</pre>');
            });
     
            $("#export-to-csv").click( function() {
    			exportExcel("treegrid");
            });
     
            $("#table-to-grid").click( function() {
              tableToGrid("#table", { width: 300, height: 'auto'});
            });
     
            $("#csv-to-table").click( function() {
              $('#view-csv').CSVToTable('data.csv');
            });
     
            // See http://stackoverflow.com/questions/2188762/php-jqgrid-export-to-excel
            function exportExcel(grid_id) {
                var grid = $("#" + grid_id)
                var mya = new Array();
                var colNames = new Array(); 
                var i = 0, j = 0, ii = 0;
                var csv = "";
     
                mya = grid.getDataIDs();          // Get All IDs
                var data = grid.getRowData(mya[0]);     // Get First row to get the labels
                for (i in data) { colNames[ii++] = i; }    // capture col names
     
                for(i = 0; i <colNames.length; i++) {
                  csv = csv + colNames[i] + "\t";     // output each Column as tab delimited
                }
                csv = csv + "\n";
     
                for(i = 0; i < mya.length; i++) {
                    data = grid.getRowData(mya[i]); // get each row
                    for( j = 0; j < colNames.length; j++) {
                        csv = csv + data[colNames[j]]+"\t"; // output each column as tab delimited
                    }
                    csv = csv + "\n";  // output each row with end of line
                }
                csv = csv + "\n";  // end of line at the end
                // alert(csv);
     
                document.forms[0].csvBuffer.value = csv;
                document.forms[0].method = 'POST';
                // send it to server which will open this contents in excel file
                document.forms[0].action = 'http://localhost:3000/Exemple 2';
                document.forms[0].target = '_blank';
                document.forms[0].submit();
            };
     
            $("#treegrid").jqGrid({
              url:'json/tree.json',
              datatype: 'json',
              mtype: 'GET',
     
              treeGrid: true,
              treeGridModel: 'adjacency',
              ExpandColumn : 'key', 
              // See http://jquery.keicode.com/ui/icons.php
              treeIcons: {leaf:'ui-icon-document'},
     
              colNames:['Key','Value'],
              colModel :[ 
                {name:'key', index:'key'}, 
                {name:'value', index:'value'}
              ],
              pager: '#pager',
              rowNum:10,
              rowList:[10,20,30],
              sortname: 'key',
              sortorder: 'desc',
              viewrecords: true,
              gridview: true,
              caption: 'Tree Grid',
                width: 400,
                height: 'auto'
            }); 
          }); 
        </script>
     
      </head>
      <body>
        <div style="margin: 20px;">
          <button id="export-to-csv">Export to CSV</button>(TAB separator)
          <table id="treegrid"></table> 
        </div>
     
        <div style="margin: 20px;">
          <button id="table-to-grid">Tabel-to-grid</button>
          <table id="table" border="1">
    	<tr>
              <th>header 1</th>
              <th>header 2</th>
    	</tr>
    	<tbody>
              <tr>
                <td>data 1</td>
                <td>data 1</td>
            </tr>
              <tr>
                <td>data 2</td>
                <td>data 2</td>
              </tr>
    	</tbody>
          </table>
        </div>
     
        <div style="margin: 20px;">
          See <a href="http://code.google.com/p/jquerycsvtotable/">http://code.google.com/p/jquerycsvtotable/</a>
          <br/>
          CSV Data: <a href="data.csv">data.csv</a>
          <div id="CSVSource" style="border: solid 1px;"></div>
          <button id="csv-to-table">csv to table</button>
          <div id="view-csv"></div>
        </div>
     
    <form method="post" action="csvExport.php">
        <input type="hidden" name="csvBuffer" id="csvBuffer" value="" />
    </form>
     
      </body>
    </html>
    Mais je n'ai pas ce que je chercher, peux-tu regarder quand tu as à un petit moment
    Merci
    Cdlt
    Zozotitou

  4. #4
    Modérateur

    Avatar de NoSmoking
    Homme Profil pro
    Inscrit en
    Janvier 2011
    Messages
    17 198
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations forums :
    Inscription : Janvier 2011
    Messages : 17 198
    Par défaut
    Bonjour,
    Merci Bernard pour ton lieu,
    cela me fait me rappeler de Philippe Khorsand

  5. #5
    Membre confirmé
    Homme Profil pro
    Inscrit en
    Janvier 2008
    Messages
    92
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Janvier 2008
    Messages : 92
    Par défaut
    Citation Envoyé par NoSmoking Voir le message
    Bonjour,
    cela me fait me rappeler de Philippe Khorsand
    Bonjour,

    Je ne comprends pas, c'est pas grave !!

    Je voudrais exécuter cette ligne sur mon pc et nom sur un site.

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
     
    CSV To Table - made sortable using <a target="_blank" href="http://tablesorter.com/">jQuery tablesorter:</a><br>
    Cdlt
    Zozotirou

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. Réponses: 2
    Dernier message: 07/04/2008, 16h37
  2. extraire un fichier CSV sous QT 3.38
    Par emil_2 dans le forum Qt
    Réponses: 5
    Dernier message: 21/03/2008, 14h26
  3. lire fichier csv et en extraire des infos
    Par isaglada dans le forum VBScript
    Réponses: 2
    Dernier message: 12/02/2007, 13h04
  4. Réponses: 1
    Dernier message: 26/01/2007, 08h15
  5. Extraire des données dans un fichier .csv
    Par orj30754 dans le forum C
    Réponses: 7
    Dernier message: 03/11/2006, 14h48

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