forked from dfEric/pandaOS
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjava.js
46 lines (40 loc) · 1.34 KB
/
java.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// ==UserScript==
// @name New Userscript
// @namespace https://viayoo.com/
// @version 10000
// @description try to take over the world!
// @author You
// @run-at document-start
// @match *
// @grant all
// ==/UserScript==
(function() {
'use strict';
import java.io.FileOutputStream;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.xssf.streaming.SXSSFWorkbook;
public class ExcelExporter {
public static void exportData(List<List<String>> data, String filePath) throws IOException {
// 创建工作簿
Workbook workbook = new SXSSFWorkbook();
// 创建工作表
Sheet sheet = workbook.createSheet();
// 遍历数据,并将其写入工作表
for (int i = 0; i < data.size(); i++) {
Row row = sheet.createRow(i);
List<String> rowData = data.get(i);
for (int j = 0; j < rowData.size(); j++) {
row.createCell(j).setCellValue(rowData.get(j));
}
}
// 将工作簿写入文件
FileOutputStream out = new FileOutputStream(filePath);
workbook.write(out);
out.close();
workbook.close();
}
}
// Your code here...
})();