springboot集成luckysheet
时间: 2023-11-15 17:55:41 浏览: 129
要在Spring Boot中集成Luckysheet,可以按照以下步骤进行:
1. 在pom.xml文件中添加以下依赖:
```
<dependency>
<groupId>com.github.luckysheet</groupId>
<artifactId>luckysheet</artifactId>
<version>https://github.com/mengshukeji/LuckysheetServer/releases/download/v1.0.0/luckysheet-1.0.0.jar</version>
</dependency>
```
2. 在Spring Boot的配置文件中添加以下配置:
```
luckysheet:
file:
path: /path/to/save/file
```
3. 在Controller中添加以下代码:
```
@GetMapping("/luckysheet")
public String luckysheet() {
return "luckysheet";
}
```
4. 在resources/templates目录下创建luckysheet.html文件,并添加以下代码:
```
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Luckysheet Demo</title>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/css/pluginsCss.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/plugins.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/luckysheet/dist/css/pluginsCss.css" />
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/luckysheet/dist/css/luckysheet.css" />
</head>
<body>
<div id="luckysheet"></div>
<script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/js/plugin.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/plugins/js/plugins.js"></script>
<script src="https://cdn.jsdelivr.net/npm/luckysheet/dist/js/luckysheet.umd.js"></script>
<script>
$(function() {
$('#luckysheet').luckysheet({
container: 'luckysheet',
title: 'Luckysheet Demo',
lang: 'zh',
data: [],
plugins: [
'chart',
'luckysheet-scroll',
'image',
'luckysheet-postil',
'luckysheet-freezen',
'luckysheet-magic-style',
'luckysheet-row-extend',
'luckysheet-multi-copy',
'luckysheet-row-hide',
'luckysheet-column-hide',
'luckysheet-row-fixed',
'luckysheet-column-fixed',
'zoom',
'filter',
'luckysheet-condition-format',
'luckysheet-pivotTable',
'hyperlink'
]
});
});
</script>
</body>
</html>
```
5. 运行Spring Boot应用程序,并在浏览器中访问http://localhost:8080/luckysheet,即可看到Luckysheet表格。
阅读全文