Skip to content

Commit 06e204f

Browse files
update java demo to v24.12
1 parent ab21250 commit 06e204f

File tree

7 files changed

+68
-15
lines changed

7 files changed

+68
-15
lines changed

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>24.10</version>
54+
<version>24.12</version>
5555
</dependency>
5656
<dependency>
5757
<groupId>com.aspose</groupId>
5858
<artifactId>aspose-cells</artifactId>
59-
<version>24.10</version>
59+
<version>24.12</version>
6060
<classifier>gridjs</classifier>
6161
</dependency>
6262
<!-- <dependency>

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import org.springframework.boot.SpringApplication;
55
import org.springframework.boot.autoconfigure.SpringBootApplication;
66

7+
import com.aspose.cells.Workbook;
78
import com.aspose.gridjs.Config;
89
import com.aspose.gridjs.GridJsWorkbook;
910

@@ -21,6 +22,8 @@ private void init() {
2122
cachePath = this.cachePathProperty;
2223
try {
2324
Config.setFileCacheDirectory(cachePath);
25+
//lazy loading
26+
Config.setLazyLoading(true);
2427
} catch (Exception e) {
2528
e.printStackTrace();
2629
}
@@ -30,6 +33,7 @@ private void init() {
3033

3134
LocalFileCache mwc = new LocalFileCache();
3235
GridJsWorkbook.CacheImp = mwc;
36+
GridJsWorkbook.UpdateMonitor = new ModifyMonitor();
3337
}
3438

3539
//simple way not use GridJsWorkbook.CacheImp ,shall also ok
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package com.aspose.gridjs.demo;
2+
3+
import java.util.ArrayList;
4+
5+
import com.aspose.cells.Workbook;
6+
7+
public class ModifyMonitor extends com.aspose.gridjs.GridUpdateMonitor{
8+
9+
@Override
10+
public void afterUpdate(String operation, String uid, ArrayList cells) {
11+
System.out.println("afterUpdate operation is:"+operation+" ,uid is:"+uid+",modified cells count:"+cells.size());
12+
13+
}
14+
15+
@Override
16+
public void beforeUpdate(String operation, String uid, Workbook wb) {
17+
System.out.println("beforeUpdate operation is:"+operation+" ,uid is:"+uid+",workbook sheets count:"+wb.getWorksheets().getActiveSheetName());
18+
19+
}
20+
21+
}

Examples.GridJs/src/main/java/com/aspose/gridjs/demo/controller/GridJs2Controller.java

Lines changed: 33 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,28 +10,24 @@
1010
import java.nio.file.Files;
1111
import java.nio.file.Path;
1212
import java.nio.file.Paths;
13-
import java.util.ArrayList;
14-
import java.util.List;
1513
import java.util.concurrent.ExecutorService;
1614
import java.util.concurrent.Executors;
1715
import java.util.zip.GZIPOutputStream;
1816

19-
import javax.servlet.http.HttpServletRequest;
20-
import javax.servlet.http.HttpServletResponse;
21-
import javax.servlet.http.Part;
22-
2317
import org.springframework.beans.factory.annotation.Value;
2418
import org.springframework.core.io.InputStreamResource;
2519
import org.springframework.http.HttpHeaders;
2620
import org.springframework.http.HttpStatus;
2721
import org.springframework.http.MediaType;
2822
import org.springframework.http.ResponseEntity;
2923
import org.springframework.web.bind.annotation.GetMapping;
24+
import org.springframework.web.bind.annotation.PathVariable;
3025
import org.springframework.web.bind.annotation.PostMapping;
3126
import org.springframework.web.bind.annotation.RequestMapping;
3227
import org.springframework.web.bind.annotation.RequestParam;
3328
import org.springframework.web.bind.annotation.RestController;
3429
import org.springframework.web.multipart.MultipartFile;
30+
import org.springframework.web.servlet.ModelAndView;
3531
import org.springframework.web.servlet.mvc.method.annotation.StreamingResponseBody;
3632

3733
import com.aspose.cells.Workbook;
@@ -40,6 +36,10 @@
4036
import com.aspose.gridjs.GridInterruptMonitor;
4137
import com.aspose.gridjs.GridJsWorkbook;
4238

39+
import javax.servlet.http.HttpServletRequest;
40+
import javax.servlet.http.HttpServletResponse;
41+
import javax.servlet.http.Part;
42+
4343
@RestController
4444
@RequestMapping({"/GridJs2"})
4545
public class GridJs2Controller {
@@ -81,8 +81,11 @@ public void detailStreamJsonWithUid(@RequestParam String filename, @RequestParam
8181
response.setContentType("application/json");
8282
response.setHeader("Content-Encoding", "gzip");
8383
try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(response.getOutputStream())) {
84-
wbj.importExcelFile(filePath.toString());
84+
boolean isdone= wbj.jsonToStreamByUid(gzipOutputStream,uid, filename);
85+
if (!isdone) {
86+
wbj.importExcelFile(uid,filePath.toString());
8587
wbj.jsonToStream(gzipOutputStream, filename);
88+
}
8689
} catch (IOException e) {
8790
// TODO Auto-generated catch block
8891
e.printStackTrace();
@@ -92,6 +95,28 @@ public void detailStreamJsonWithUid(@RequestParam String filename, @RequestParam
9295
}
9396
}
9497

98+
@PostMapping("/LazyLoading")
99+
public void lazyLoadingStreamJson(
100+
@RequestParam(value = "name", required = false) String sheetName,
101+
@RequestParam(value = "uid", required = false) String uid,
102+
HttpServletResponse response) throws IOException {
103+
104+
GridJsWorkbook wbj = new GridJsWorkbook();
105+
106+
// ÉèÖÃÏìӦͷ
107+
response.setContentType(MediaType.APPLICATION_JSON_VALUE);
108+
response.setHeader(HttpHeaders.CONTENT_ENCODING, "gzip");
109+
110+
try (GZIPOutputStream gzipOutputStream = new GZIPOutputStream(response.getOutputStream())) {
111+
try {
112+
wbj.lazyLoadingStream(gzipOutputStream, uid, sheetName);
113+
} catch (Exception e) {
114+
// TODO Auto-generated catch block
115+
e.printStackTrace();
116+
}
117+
}
118+
}
119+
95120
@PostMapping("/UpdateCell")
96121
public ResponseEntity<String> updateCell(HttpServletRequest request) {
97122
String p = request.getParameter("p");
@@ -498,4 +523,4 @@ public ResponseEntity<String> download(HttpServletRequest request) {
498523
}
499524

500525

501-
}
526+
}

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
<script src="/xspread/xspreadsheet.js?v=20230525"></script> -->
3636

3737
<!--for release reference-->
38-
<link rel="stylesheet" href="https://unpkg.com/gridjs-spreadsheet@24.11.1/xspreadsheet.css">
39-
<script src="https://unpkg.com/gridjs-spreadsheet@24.11.1/xspreadsheet.js"></script>
38+
<link rel="stylesheet" href="https://unpkg.com/gridjs-spreadsheet@24.12.0/xspreadsheet.css">
39+
<script src="https://unpkg.com/gridjs-spreadsheet@24.12.0/xspreadsheet.js"></script>
4040

4141

4242

@@ -143,6 +143,7 @@
143143
const imageuploadurl1 = "/GridJs2/AddImage";
144144
const imageuploadurl2 = "/GridJs2/AddImageByURL";
145145
const imagecopyurl = "/GridJs2/CopyImage"; // x.spreadsheet.locale('zh-cn');
146+
const lazyLoadingUrl = "/GridJs2/LazyLoading";
146147
xs = x_spreadsheet('#gridjs-demo-uid', option).loadData(sheets).change((cdata) => {
147148
console.log(cdata);
148149
console.log(xs.validate());
@@ -192,6 +193,8 @@
192193
xs.setImageInfo(imageurl, imageuploadurl1, imageuploadurl2, imagecopyurl, basiczorder);
193194
xs.setFileDownloadInfo(fileDownloadUrl);
194195
xs.setOleDownloadInfo(oleDownloadUrl);
196+
//lazy loading
197+
xs.setLazyLoadingUrl(lazyLoadingUrl);
195198

196199
let activeSheetName = jsondata.actname;
197200

Examples.GridWeb/springboot3.3demo/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
<dependency>
4040
<groupId>com.aspose</groupId>
4141
<artifactId>aspose-cells</artifactId>
42-
<version>24.11</version>
42+
<version>24.12</version>
4343
<classifier>gridweb-jakarta</classifier>
4444
</dependency>
4545
</dependencies>

Examples.GridWeb/springdemo/pom.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>com.aspose.gridweb</groupId>
77
<artifactId>gridwebspringdemo</artifactId>
8-
<version>24.11</version>
8+
<version>24.12</version>
99
<name>gridweb-spring-demo</name>
1010
<description>gridweb spring demo</description>
1111
<packaging>jar</packaging>
@@ -59,7 +59,7 @@
5959
<dependency>
6060
<groupId>com.aspose</groupId>
6161
<artifactId>aspose-cells</artifactId>
62-
<version>24.11</version>
62+
<version>24.12</version>
6363
<classifier>gridweb</classifier>
6464
</dependency>
6565
<!-- <dependency>

0 commit comments

Comments
 (0)