Visualizzazione dei risultati da 1 a 1 su 1
  1. #1
    Utente di HTML.it
    Registrato dal
    Jul 2007
    Messaggi
    303

    Importazione file XLSX con DROPZONE

    ragazzi sto cercando di importare un file XLSX con dropzone, ma non funziona ..... dove sbaglio ???
    per me errore sta qui:
    addedfile: function(file){ var data ="upload/" +file.name;var workbook = XLSX.readFile(data)}
    ma non capisco quale errore sia...
    grazie in anticipo.
    ecco il codice html:
    codice:
    <div id="file-upload">
        <div class="panel panel-light">
            <div class="panel-heading">
                <div class="panel-title">
                    <h4>Importa Dati Capitolati</h4>
                </div>
            </div>
            <div class="panel-body">
                <section>
                  <div id="dropzone">
                    <form class="dropzone needsclick" id="demoupload" action="/upload">
                      <div class="dz-message needsclick">
                          Trascina file qui o click per upload.<br>                      
                          <span class="note needsclick fa fa-download fa-4x" style="color:blue"></span>
                      </div>
                    </form>
                  </div>
                </section>
              <hr size="3" noshade color="#F00000">
              <div id="preview-template" style="display: none;">
                <div class="dz-preview dz-file-preview">
                  <div class="dz-image"><img data-dz-thumbnail=""></div>
                  <div class="dz-details">
                    <div class="dz-size"><span data-dz-size=""></span></div>
                    <div class="dz-filename"><span data-dz-name=""></span></div>
                  </div>
                  <div class="dz-progress"><span class="dz-upload" data-dz-uploadprogress=""></span></div>
                  <div class="dz-error-message"><span data-dz-errormessage=""></span></div>
                  <div class="dz-success-mark"></div>
                  <div class="dz-error-mark"></div>
                </div>
              </div>          
            </div>
        </div>
    </div>
        <div id="dvExcel">
        </div>
    ecco il codice
    codice:
      var dropzone = new Dropzone('#demoupload', {
                  previewTemplate: document.querySelector('#preview-template').innerHTML,
                  parallelUploads: 2,
                  autoProcessQueue: false,
                  thumbnailHeight: 120,
                  thumbnailWidth: 120,
                  maxFilesize: 3,
                  validation: {
                       allowedExtensions: [".xls", ".html", ".xlsx"]
                  },
                  showFileList: false,
                  addRemoveLinks: true,
                  filesizeBase: 1000,
                  dictRemoveFile:"Rimuovi File",
                  thumbnail: function(file, dataUrl) {
                     if (file.previewElement) {
                         file.previewElement.classList.remove("dz-file-preview");
                         var images = file.previewElement.querySelectorAll("[data-dz-thumbnail]");
                         for (var i = 0; i < images.length; i++) {
                           var thumbnailElement = images[i];
                           thumbnailElement.alt = file.name;
                           thumbnailElement.src = dataUrl;
                         }
                         setTimeout(function() { file.previewElement.classList.add("dz-image-preview"); }, 1);
                       }
                     },
              addedfile: function(file){
                var data ="upload/" +file.name;                       
                var workbook = XLSX.readFile(data)
                var firstSheet = workbook.SheetNames[0];
                //Read all rows from First Sheet into an JSON array.
                var excelRows = XLSX.utils.sheet_to_row_object_array(workbook.Sheets[firstSheet]);
                //Create a HTML Table element.
                var table = $("<table />");
                table[0].border = "1";
                //Add the header row.
                var row = $(table[0].insertRow(-1));
                //Add the header cells.
                var headerCell = $("<th />");
                headerCell.html("CODICE");
                row.append(headerCell);
                var headerCell = $("<th />");
                headerCell.html("NOME");
                row.append(headerCell);
                var headerCell = $("<th />");
                headerCell.html("IMPORTO");
                row.append(headerCell);
                //Add the data rows from Excel file.
                for (var i = 0; i < excelRows.length; i++) {
                    //Add the data row.
                    var row = $(table[0].insertRow(-1));
                    //Add the data cells.
                    var cell = $("<td />");
                    cell.html(excelRows[i].CODICE);
                    row.append(cell);
                    cell = $("<td />");
                    cell.html(excelRows[i].NOME);
                    row.append(cell);
                    cell = $("<td />");
                    cell.html(excelRows[i].IMPORTO);
                    row.append(cell);
                }
                var dvExcel = $("#dvExcel");
                dvExcel.html("");
                dvExcel.append(table);
                  }
               })
    Ultima modifica di max1974; 08-04-2019 a 12:28

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2019 vBulletin Solutions, Inc. All rights reserved.