Skip to content

Commit b715373

Browse files
update gridjs java demo
1 parent afb27a6 commit b715373

File tree

7 files changed

+56
-29
lines changed

7 files changed

+56
-29
lines changed

Examples.GridJs/README.md

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,39 @@
11
# Aspose.Cells for Java
22
[Aspose.Cells.GridJs for Java](http://www.aspose.com/products/cells/java) 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, and provides easy-to-use APIs.
33

4-
## How to Run the Examples
5-
1.edit the properties in src\main\resources\application.properties
4+
## Preview
65

7-
#This is the excel directory to browse
8-
testconfig.ListDir=/app/wb
6+
<img alt='demo' src='https://unpkg.com/[email protected]/preview.gif' />
97

10-
#Specific the spreadsheet file name in the directory to browse
11-
testconfig.FileName=chart.xlsx
8+
## How to Run the Examples
9+
###1.edit the properties in src\main\resources\application.properties to meet your local environment
10+
```properties
11+
# This is the directory contains the spread sheet files
12+
testconfig.ListDir=/app/wb
1213

13-
#Directory for storing cache files
14+
# Directory for storing cache files
1415
testconfig.CachePath=/app/grid_cache
1516

16-
2.run src\main\java\com\aspose\gridjs\demo\GridjsdemoApplication.java
17+
# Directory for storing upload files
18+
testconfig.UploadPath=/app/upload
1719

18-
open browser and navigate to view the default spreadsheet file at http://localhost:8080/gridjsdemo/index or view all the files in the directory at http://localhost:8080/gridjsdemo/list
20+
# License file for Aspose.Cells
21+
testconfig.AsposeLicensePath=/app/license
22+
```
23+
###2.run src\main\java\com\aspose\gridjs\demo\GridjsdemoApplication.java
1924

20-
## Step to run in docker
25+
open browser and navigate to view all the files in the directory at http://localhost:8080/gridjsdemo/list
2126

22-
docker build -t gridjs-demo-java .
27+
## Step to run in docker
2328

24-
docker run -d -p 8080:8080 gridjs-demo-java
29+
1. docker build -t gridjs-demo-java .
2530

26-
open browser and enter the url:http://localhost:8080/gridjsdemo/index or http://localhost:8080/gridjsdemo/list
31+
2. run with aspose license file:
32+
docker run -d -p 8080:8080 -v C:/path/to/license.txt:/app/license gridjs-demo-java
33+
or just run the demo in trial mode:
34+
docker run -d -p 8080:8080 gridjs-demo-java
35+
36+
3. open browser and enter the url: http://localhost:8080/gridjsdemo/list
2737

2838
## Resources
2939

Examples.GridJs/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,12 @@
5151
<dependency>
5252
<groupId>com.aspose</groupId>
5353
<artifactId>aspose-cells</artifactId>
54-
<version>25.1</version>
54+
<version>25.2</version>
5555
</dependency>
5656
<dependency>
5757
<groupId>com.aspose</groupId>
5858
<artifactId>aspose-cells</artifactId>
59-
<version>25.1</version>
59+
<version>25.2</version>
6060
<classifier>gridjs</classifier>
6161
</dependency>
6262
<!-- <dependency>

Examples.GridJs/src/main/java/com/aspose/gridjs/demo/GridjsdemoApplication.java

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
import com.aspose.gridjs.Config;
1111
import com.aspose.gridjs.GridJsWorkbook;
1212

13+
import java.io.File;
14+
1315
import javax.annotation.PostConstruct;
1416

1517

@@ -81,9 +83,11 @@ public static void main(String[] args) {
8183

8284
MyConfig myConfig = context.getBean(MyConfig.class);
8385

84-
//set license for aspose cells
86+
//set license for Aspose.Cells
8587
com.aspose.cells.License lic=new com.aspose.cells.License();
86-
//lic.setLicense(myConfig.asposeLicensePath);
88+
if ((new File(myConfig.asposeLicensePath)).exists()) {
89+
lic.setLicense(myConfig.asposeLicensePath);
90+
}
8791
init(myConfig);
8892

8993
}

Examples.GridJs/src/main/resources/application.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,6 @@ testconfig.ListDir=/app/wb
88
testconfig.FileName=chart.xlsx
99
testconfig.CachePath=/app/grid_cache
1010
testconfig.UploadPath=/app/upload
11-
testconfig.AsposeLicensePath=/app/aspose.lic
11+
testconfig.AsposeLicensePath=/app/license
1212

1313

Examples.GridJs/src/main/resources/templates/fileFromUpload.html

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
.big-div, canvas {
4141
width: 100%;
4242
height: 100%;
43-
object-fit: contain;
43+
object-fit: contain; /* 对于图像或视频很有用 */
4444
}
4545
</style>
4646
<!--<link rel="stylesheet" href="./quantumui.min.22.5.5.2.css?v=20220312" />-->
@@ -51,12 +51,13 @@
5151
<script src="/xspread/jszip.min.js"></script>
5252
<!-- <script src="vconsole.min.js"></script> -->
5353
<!--for local reference-->
54+
<!--
5455
<link rel="stylesheet" href="/xspread/xspreadsheet.css?v=20230525" />
5556
<script src="/xspread/xspreadsheet.js?v=20230525"></script>
56-
57+
-->
5758
<!--for release reference-->
58-
<!-- <link rel="stylesheet" href="https://unpkg.com/gridjs-spreadsheet@24.12.0/xspreadsheet.css">
59-
<script src="https://unpkg.com/gridjs-spreadsheet@24.12.0/xspreadsheet.js"></script> -->
59+
<link rel="stylesheet" href="https://unpkg.com/gridjs-spreadsheet/xspreadsheet.css">
60+
<script src="https://unpkg.com/gridjs-spreadsheet/xspreadsheet.js"></script>
6061

6162

6263

Examples.GridJs/src/main/resources/templates/index.html

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,12 +51,14 @@
5151
<script src="/xspread/jszip.min.js"></script>
5252
<!-- <script src="vconsole.min.js"></script> -->
5353
<!--for local reference-->
54-
<link rel="stylesheet" href="/xspread/xspreadsheet.css?v=20230525" />
54+
<!--
55+
<link rel="stylesheet" href="/xspread/xspreadsheet.css?v=20230525" />
5556
<script src="/xspread/xspreadsheet.js?v=20230525"></script>
57+
-->
5658

5759
<!--for release reference-->
58-
<!-- <link rel="stylesheet" href="https://unpkg.com/gridjs-spreadsheet@24.12.0/xspreadsheet.css">
59-
<script src="https://unpkg.com/gridjs-spreadsheet@24.12.0/xspreadsheet.js"></script> -->
60+
<link rel="stylesheet" href="https://unpkg.com/gridjs-spreadsheet/xspreadsheet.css">
61+
<script src="https://unpkg.com/gridjs-spreadsheet/xspreadsheet.js"></script>
6062

6163

6264

Examples.GridJs/src/main/resources/templates/list.html

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,28 @@
7171
const url = '/gridjsdemo/Uidtml?filename=' + filename+'&uid='+uid;
7272
window.open(url, "_blank");
7373
}
74+
document.addEventListener('DOMContentLoaded', function() {
75+
document.getElementById('fileInput').addEventListener('change', function(event) {
76+
const file = event.target.files[0];
77+
if (file) {
78+
//console.log('文件已选择:', file.name);
79+
document.getElementById('uploadForm').submit();
80+
}
81+
});
82+
});
7483
</script>
7584
<!-- 文件上传表单 -->
7685

7786
<div class="upload-form">
78-
<form method="post" action="/gridjsdemo/upload" enctype="multipart/form-data">
87+
<h4>Upload a local file to start show workbook</h4>
88+
<form id="uploadForm" method="post" action="/gridjsdemo/upload" enctype="multipart/form-data" >
7989
<!-- accept属性用于限定可接受的文件类型 -->
80-
<input type="file" name="file" accept=".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" required/>
81-
<button type="submit">upload</button>
90+
<input id="fileInput" type="file" name="file" accept=".xlsx,application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" required/>
91+
8292
</form>
8393
</div>
8494
<div class="file-list">
85-
<h2>choose a file from the navigation path</h2>
95+
<h4>Navigate one of the below file to start show workbook</h4>
8696
<div th:each="item : ${filelist}">
8797
<a href="javascript:void(0)" target="_blank" th:data-filename="${item[0]}" th:data-uid="${item[1]}" onclick="openfile(this)">
8898
<em th:text="${item[0]}"></em>

0 commit comments

Comments
 (0)