Hello, use the aspose. wrod. java package to convert the HTML file into a wrod table.
The data lines and table headers are incorrect, and the code is as follows:
Document doc = new Document("E:\\测试文档\\1.html");
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2019);
doc.save("E:\\测试文档\\1.docx", SaveFormat.DOCX);
file.zip (157.7 KB)
@Mikeykiss Unfortunately, I cannot reproduce the problem on my side. As I can see table looks fine in MS Word 2019:
May I ask which version of aspose.wrod.java you are using? I am using version 21.4 on my end, but it is still incorrect to transfer it out
@Mikeykiss I have used the latest 23.9 version of Aspose.Words for Java. But I also do not see the problem in the DOCX document you have attached in the initial post when open it using MS Word 2019 version.
I have used the latest version of aspose, but there is an issue with the data in the last row of the table. Is it because I don’t have a license
image.png (302.7 KB)
@Mikeykiss Yes, your document is truncated due to the evaluation version limitations. If you would like to test new version of Aspose.Words without evaluation version limitations, you can request a free 30-days temporary license .
Hello, I have encountered the previous issue with the latest version. Please take a look at the pictures and the problem file
Document doc = new Document("E:\\测试文档\\input.html");
doc.save("E:\\测试文档\\2.docx", SaveFormat.DOCX);
1.zip (164.8 KB)
@Mikeykiss Unfortunately, I do not see the problem in the output document on my side. The docment looks fine in MS Word 2019:
So Aspose.Words output is correct.
Hello, I have indeed encountered this issue on my end. I encountered a problem with the file I opened using Microsoft Office Professional Enhanced Edition 2016. How should I solve this problem on my end
@Mikeykiss Looks like a bug in MS Word 2016. Please try using the following code:
Document doc = new Document("C:\\Temp\\issues paper.html");
doc.getCompatibilityOptions().optimizeFor(MsWordVersion.WORD_2016);
doc.save("C:\\Temp\\out.docx");
Hello, may I ask if there is a method for handling all compatible versions here
@Mikeykiss You can use CompatibilityOptions.optimizeFor
method to optimize the document for a specific version of MS Word. This method sets the appropriate compatibility options to make the document look as in the specified version of MS Word. Different versions of MS Word might displayed the same document differently.
Hello, this method CompatibilityOptions.optimizeFor can indeed set compatibility options for the specified version. Different users have different versions of Office, so the displayed tables are also incorrect. The tables are somewhat disordered, so is there a method to uniformly set MS Word to optimize the documents
@Mikeykiss You can try optimizing for the lowest available version. But still all depends on the MS Word used by the user.