parent
239300ce97
commit
d5f81a10e3
@ -0,0 +1,8 @@
|
||||
# 默认忽略的文件
|
||||
/shelf/
|
||||
/workspace.xml
|
||||
# Editor-based HTTP Client requests
|
||||
/httpRequests/
|
||||
# Datasource local storage ignored files
|
||||
/dataSources/
|
||||
/dataSources.local.xml
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<module type="PYTHON_MODULE" version="4">
|
||||
<component name="NewModuleRootManager">
|
||||
<content url="file://$MODULE_DIR$" />
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
</component>
|
||||
</module>
|
@ -0,0 +1,14 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<profile version="1.0">
|
||||
<option name="myName" value="Project Default" />
|
||||
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
|
||||
<option name="ignoredPackages">
|
||||
<value>
|
||||
<list size="1">
|
||||
<item index="0" class="java.lang.String" itemvalue="st-chat" />
|
||||
</list>
|
||||
</value>
|
||||
</option>
|
||||
</inspection_tool>
|
||||
</profile>
|
||||
</component>
|
@ -0,0 +1,6 @@
|
||||
<component name="InspectionProjectProfileManager">
|
||||
<settings>
|
||||
<option name="USE_PROJECT_PROFILE" value="false" />
|
||||
<version value="1.0" />
|
||||
</settings>
|
||||
</component>
|
@ -0,0 +1,4 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10 (JianYingApi-main)" project-jdk-type="Python SDK" />
|
||||
</project>
|
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/.idea/Py.iml" filepath="$PROJECT_DIR$/.idea/Py.iml" />
|
||||
</modules>
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="VcsDirectoryMappings">
|
||||
<mapping directory="$PROJECT_DIR$/.." vcs="Git" />
|
||||
</component>
|
||||
</project>
|
@ -0,0 +1,49 @@
|
||||
# pip install pywin32
|
||||
# https://blog.csdn.net/weixin_42927998/article/details/115086797
|
||||
import win32com
|
||||
from win32com.client import Dispatch
|
||||
|
||||
docApp = win32com.client.Dispatch('Word.Application')
|
||||
# 是不是打Word显示
|
||||
docApp.Visible = False
|
||||
docApp.DisplayAlerts = 0
|
||||
# doc = docApp.Documents.Open('c:/1.docx')
|
||||
# doc = docApp.Documents.Open('c:/昭通市人口变化及其对教育的影响20240416.docx')
|
||||
# doc = docApp.Documents.Open('c:/昆明市人口变化及其对教育的影响20240419.docx')
|
||||
doc = docApp.Documents.Open('c:/红河哈尼族彝族自治州人口变化及其对教育的影响20240419.docx')
|
||||
|
||||
|
||||
# 遍历文档中所有的文字段落,判断是不是以 图+数字开头
|
||||
idx = 1
|
||||
for para in doc.Paragraphs:
|
||||
x = para.Range.Text.strip().replace("图 ", "图").replace(" ", " ")
|
||||
if x.startswith("图"):
|
||||
print(x)
|
||||
idx = idx + 1
|
||||
|
||||
# 遍历文档中的所有内嵌形状
|
||||
idx = 1
|
||||
for inline_shape in doc.InlineShapes:
|
||||
if inline_shape.Type == win32com.client.constants.wdInlineShapeChart: # 检查是否为内嵌图表
|
||||
shape = doc.InlineShapes(idx)
|
||||
# 获取图表的标题,此项目中图表没有标题
|
||||
# print(shape.Chart.ChartTitle.Text)
|
||||
sheet = shape.Chart.ChartData.Workbook.Worksheets("Sheet1")
|
||||
# 行数
|
||||
row_size = sheet.UsedRange.rows.Count
|
||||
# 列数
|
||||
col_size = sheet.UsedRange.columns.Count
|
||||
# 遍历获取表格中的数据
|
||||
for i in range(1, row_size + 1):
|
||||
for j in range(1, col_size + 1):
|
||||
print(sheet.Cells(i, j).Value, end=" ")
|
||||
print("")
|
||||
print("")
|
||||
# 下一个图表的索引号
|
||||
idx = idx + 1
|
||||
print(idx-1)
|
||||
|
||||
|
||||
# 关闭文档和Word应用
|
||||
doc.Close()
|
||||
docApp.Quit()
|
@ -0,0 +1,32 @@
|
||||
package com.dsideal.base.Test;
|
||||
|
||||
import org.apache.poi.xwpf.usermodel.*;
|
||||
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
public class TestReadWord {
|
||||
public static void main(String[] args) throws IOException {
|
||||
String path="c:/昭通市人口变化及其对教育的影响20240416.docx";
|
||||
FileInputStream fis = new FileInputStream(path);
|
||||
XWPFDocument document = new XWPFDocument(fis);
|
||||
|
||||
// 遍历文档中的段落
|
||||
for (XWPFParagraph paragraph : document.getParagraphs()) {
|
||||
for (XWPFRun run : paragraph.getRuns()) {
|
||||
List<XWPFPicture> pictures = run.getEmbeddedPictures();
|
||||
if (pictures != null) {
|
||||
for (XWPFPicture pictureData : pictures) {
|
||||
System.out.println( pictureData.getPictureData().getPictureType());
|
||||
System.out.println( pictureData.getPictureData().getFileName());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
document.close();
|
||||
fis.close();
|
||||
}
|
||||
}
|
Loading…
Reference in new issue