main
黄海 8 months ago
parent 0720752da2
commit c8fadc38e8

@ -15,7 +15,7 @@ if __name__ == '__main__':
docApp = win32com.client.Dispatch('Word.Application')
# 是否显示Word文档
docApp.Visible = False
docApp.Visible = True
docApp.DisplayAlerts = 0
doc = docApp.Documents.Open(docPath)

@ -49,7 +49,8 @@ public class C9 {
workbook.close();
//如果达到目标预期的数量就直接返回poi获取的数据列表
if (data.size() < expectLimit) {
int totalRow = data.size() + skipRowCount;
if (totalRow < expectLimit) {
System.out.println("数据不足,重新获取数据,现正在使用python_docx进行二次获取数据...");
//否则调用python+com进行再次获取数据列表这次获取的可能才是对的
//写入交互文本文件
@ -98,20 +99,12 @@ public class C9 {
//判断是否为docx文件
if (fileName.endsWith(".docx") && !fileName.startsWith("~")) {
System.out.println("正在处理" + cityName + "市州文件...");
//读取文件
//数据在图表1
int firstChartNumber = 1;
List<List<String>> source1 = getChartData(file.getAbsolutePath(), firstChartNumber, 6,20);//2017年开始
if (cityName.contains("丽江")) {
System.out.println("丽江");
System.out.println(source1);
}
int chartNumber = 1;
List<List<String>> source = getChartData(file.getAbsolutePath(), chartNumber, 6, 20);//2017年开始
//遍历source1
for (List<String> r : source1) {
for (List<String> r : source) {
Row outRow = outSheet.createRow(++rowIndex);
// 导出数据
//上级行政区划,行政区划,年份,总人口变化,总人口预测

@ -347,8 +347,7 @@ public class ExcelKit {
* @throws InterruptedException
*/
public static void callPythonRead() throws IOException, InterruptedException {
ExcelKit.delExcel(excelPath);
delExcel(excelPath);
// 创建ProcessBuilder对象并设置Python脚本的路径
ProcessBuilder processBuilder = new ProcessBuilder(python, py);
// 重定向错误流到标准输出这样可以在Java中捕获所有的输出

Loading…
Cancel
Save