gridjs-spreadsheet
Version:
this is the client side script for GridJs which is a lightweight, scalable, and customizable toolkit that provides cross-platform web applications, enables convenient development for editing or viewing Excel/Spreadsheet files, offers simple deployment, an
109 lines (100 loc) • 3.3 kB
HTML
<html lang="en">
<head>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width" />
<title>gridjs-web-demo file list</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f4f4f4;
}
.container {
width: 80%;
margin: auto;
overflow: hidden;
}
header {
background: #50b3a2;
color: #ffffff;
padding-top: 30px;
min-height: 70px;
border-bottom: #e8491d 3px solid;
}
header h1 {
text-align: center;
text-transform: uppercase;
margin: 0;
font-size: 24px;
}
.upload-form, .file-list {
background: white;
padding: 20px;
margin-top: 20px;
box-shadow: 0 0 10px rgba(0,0,0,0.1);
}
.upload-form input[type="file"], .upload-form button {
display: block;
width: 100%;
margin: 10px 0;
padding: 10px;
}
footer {
text-align: center;
padding: 20px;
background: #50b3a2;
color: white;
margin-top: 20px;
}
a {
color: #50b3a2;
text-decoration: none;
}
a:hover {
color: #e8491d;
}
</style>
</head>
<body>
<script>
function openfile(element) {
const filename = element.getAttribute('data-filename');
const uid = element.getAttribute('data-uid');
const url = '/gridjsdemo/Uidtml?filename=' + filename+'&uid='+uid;
window.open(url, "_blank");
}
document.addEventListener('DOMContentLoaded', function() {
document.getElementById('fileInput').addEventListener('change', function(event) {
const file = event.target.files[0];
if (file) {
//console.log('文件已选择:', file.name);
document.getElementById('uploadForm').submit();
}
});
});
</script>
<!-- 文件上传表单 -->
<div class="upload-form">
<h4>Upload a local file to start show workbook</h4>
<form id="uploadForm" method="post" action="/gridjsdemo/upload" enctype="multipart/form-data" >
<!-- accept属性用于限定可接受的文件类型 -->
<input id="fileInput" type="file" name="file" accept=".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" required/>
</form>
</div>
<div class="file-list">
<h4>Navigate one of the below file to start show workbook</h4>
<div th:each="item : ${filelist}">
<a href="javascript:void(0)" target="_blank" th:data-filename="${item[0]}" th:data-uid="${item[1]}" onclick="openfile(this)">
<em th:text="${item[0]}"></em>
</a><br />
</div>
</div>
<footer class="border-top footer text-muted">
<div class="container">
© 2025 - Aspose
</div>
</footer>
</body>
</html>