用JS实现excel预览

时间:2025-01-22 13:53:50
     function  loadModal(fileInfo) {
         let previewElement;
         jQuery( ".file-image-container-gaia" ).each( function  (i, e) {
             let fileName = jQuery(e).children( "a:eq(0)" ).text();
             if  (fileName ==  && jQuery(e).children( "button" ).length == 0) {
                 previewElement = jQuery(e);
                 return  false ;
             }
         });
         if  (!previewElement)  return ;
         let modalId =  'myModal'  + ;
         let tabId =  'myTab'  + ;
         let tabContentId =  'tab-content'  + ;
         let $button = $( '<button type="button" class="btn btn-default" data-toggle="modal" data-target="#'  + modalId +  '"><span class="fa fa-search"></span></button>' );
         let myModal =
             '<style type="text/css">td{word-break: keep-all;white-space:nowrap;}</style>'  +
             '<div class="modal fade tab-pane active"  tabindex="-1" role="dialog" aria-labelledby="myModalLabel">'  +
             '<div class="modal-dialog modal-xl" style="border-radius:5px" role="document">'  +
             '<div class="modal-content">'  +
             '<div class="modal-header">'  +
             '<h5 class="modal-title">'  +  +  '</h5>'  +
             '<button type="button" class="close" data-dismiss="modal" aria-label="Close">'  +
             '<span aria-hidden="true">&times;</span>'  +
             '</button>'  +
             '</div>'  +
             '<ul class="nav nav-tabs" id='  + tabId +  '>'  +
             '</ul>'  +
             '<div id='  + tabContentId +  ' class="tab-content">'  +
             '<div class="d-flex justify-content-center">'  +
             '<div class="spinner-border" role="status">'  +
             '<span class="sr-only">Loading...</span>'  +
             '</div>'  +
             '</div>'  +
             '</div>'  +
             '<div class="modal-footer">'  +
             '<button type="button" class="btn btn-secondary" data-dismiss="modal">关闭</button>'  +
             '</div>'  +
             '</div>'  +
             '</div>'  +
             '</div>' ;
         ($button);
         $( 'body' ).prepend(myModal);
         $( '#'  + modalId).on( '' function  (e) {
             loadRemoteFile(fileInfo);
         })
     }