.doc和.docx文档默认应用打开设置完word后,每次重启被自动更改为wps打开解决办法。

问题:.doc和.docx文档默认应用打开设置完word后,每次重启被自动更改为wps。让我很不理解,按照网上的教程都设置好了。
方法第1步:office的开机启动项被我自己给关闭了,当时觉得没啥用,office好像不用开机自启动,事实证明还是不行。打开电脑管家,如下图:Microsoft Office 打开自启动~

方法第2步:然而,在使用一段时间后发现还是会被篡改为wps启动,我不信改不好,在搜索大量信息后终于找到问题所在了:

WPS自带一个“配置工具”,我们在windows自带的开始处搜索“配置工具”或者去WPS安装路径找到它,如下图,并打开:

ok,重启大功告成~!!

您可以使用Apache POI库来解析Word文档,POI库支持读取和写入.doc和.docx格式的Word文档。以下是一个简单的Java代码示例,演示如何使用POI库来读取Word文档中的标题、内容和表格,并为它们添加自定义样式。请注意,这只是一个示例代码,您需要根据实际情况进行修改和优化。 ```java import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import org.apache.poi.hwpf.HWPFDocument; import org.apache.poi.hwpf.usermodel.Paragraph; import org.apache.poi.hwpf.usermodel.Table; import org.apache.poi.hwpf.usermodel.TableCell; import org.apache.poi.hwpf.usermodel.TableRow; import org.apache.poi.hwpf.usermodel.Range; import org.apache.poi.xwpf.usermodel.XWPFDocument; import org.apache.poi.xwpf.usermodel.XWPFParagraph; import org.apache.poi.xwpf.usermodel.XWPFTable; import org.apache.poi.xwpf.usermodel.XWPFTableRow; import org.apache.poi.xwpf.usermodel.XWPFTableCell; public class WordParser { public static void parse(String inputFilePath, String outputFilePath) throws IOException { if (inputFilePath.endsWith(".doc")) { parseDocFile(inputFilePath, outputFilePath); } else if (inputFilePath.endsWith(".docx")) { parseDocxFile(inputFilePath, outputFilePath); } else { throw new IllegalArgumentException("Unsupported file format"); } } private static void parseDocFile(String inputFilePath, String outputFilePath) throws IOException { FileInputStream inputStream = new FileInputStream(inputFilePath); HWPFDocument document = new HWPFDocument(inputStream); Range range = document.getRange(); FileOutputStream outputStream = new FileOutputStream(outputFilePath); for (int i = 0; i < range.numParagraphs(); i++) { Paragraph paragraph = range.getParagraph(i); String text = paragraph.text(); if (paragraph.isInTable()) { Table table = range.getTable(paragraph); for (int j = 0; j < table.numRows(); j++) { TableRow row = table.getRow(j); for (int k = 0; k < row.numCells(); k++) { TableCell cell = row.getCell(k); String cellText = cell.getParagraph(0).text(); // add custom style to cellText cell.getParagraph(0).setStyle("CustomCellStyle"); } } } else if (text.startsWith("Heading")) { // add custom style to heading paragraph.setStyle("CustomHeadingStyle"); } else { // add custom style to content paragraph.setStyle("CustomContentStyle"); } range.getParagraph(i).writeReplace(paragraph); } document.write(outputStream); outputStream.close(); inputStream.close(); } private static void parseDocxFile(String inputFilePath, String outputFilePath) throws IOException { FileInputStream inputStream = new FileInputStream(inputFilePath); XWPFDocument document = new XWPFDocument(inputStream); FileOutputStream outputStream = new FileOutputStream(outputFilePath); for (XWPFParagraph paragraph : document.getParagraphs()) { String text = paragraph.getText(); if (paragraph.getBody().getTables().size() > 0) { for (XWPFTable table : paragraph.getBody().getTables()) { for (XWPFTableRow row : table.getRows()) { for (XWPFTableCell cell : row.getTableCells()) { String cellText = cell.getText(); // add custom style to cellText cell.getParagraphs().get(0).setStyle("CustomCellStyle"); } } } } else if (text.startsWith("Heading")) { // add custom style to heading paragraph.setStyle("CustomHeadingStyle"); } else { // add custom style to content paragraph.setStyle("CustomContentStyle"); } } document.write(outputStream); outputStream.close(); inputStream.close(); } } ``` 在上面的代码中,我们使用了两个不同的类来处理.doc和.docx文件格式。对于.doc文件,我们使用HWPFDocument和Range类来获取文档的段落、表格等信息;对于.docx文件,我们使用XWPFDocument、XWPFParagraph、XWPFTable等类来获取文档的段落、表格等信息。在解析过程中,我们可以根据文本内容的特征,如标题、表格等,为它们添加自定义样式。最终,我们将修改后的文档写入到输出文件中。 请注意,在实际使用中,您需要确保您的Word文档结构良好,例如,标题应该使用Word的标题样式,而不是手动加粗或者加大字体;表格应该使用Word的表格工具,而不是手动绘制表格。否则,解析器可能无法正确识别文档中的各个部分。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值