Some popular science about the latest version 23.10 of the non-open source projects aspose.cells and aspose.words

Originally this article was written about the 23.10 version of aspose.cells, and recently it was practiced on the 23.10 version of aspose.words, so the latest versions of both were practiced.

1.Basic introduction

In our daily work, we often use Excel to do some things, and we often need to use code programs to parse Excel files. Currently, poi, easypoi, easyexcel, and jxls are used a lot, and they are all used in some specific situations. It is very good at processing Excel files, but sometimes the Excel we want to parse is not a standard xls or xlsx format file, but it can be opened normally using Excel or WPS, especially WPS compatibility, which is particularly good for some html and xml sources. As long as the file extension is in xls or xlsx format, it will always be opened directly. When opening it in Office Excel, there will also be a confirmation prompt box when opening a non-standard Excel file. For those Excel files in non-standard formats (which may be generated by amateur players using code, or they may be saved as html, xml, etc. using Excel and then manually modified into xls), I used to resolutely choose these files. Not processed.

Last time when I was writing a function to parse Excel files on a large scale, there were so many non-standard Excel files, so I had to face this problem. After some attempts, I found that the way I parsed HTML was too complicated and varied. , and it does not support saving files in xml format, so I tried to use the trial version of `aspose.cells` under the reminder of the boy next to me. It will generate an extra Sheet page when converting the format and generating Excel. Evaluation Warning", refer to the figure below:

image.png

So the final implementation is to use it to convert the format. In fact, its format conversion code is relatively simple to use and powerful. It supports many file formats, the common ones are: html, xml, csv, etc., refer to the following The code converts an HTML table page into an Excel file and returns the Workbook object:

public static void main(String[] args) throws Exception {
    String html =
            "<html>" +
                "<head>" +
                    "<title>https://www.chendd.cn</title>" +
                "</head>" +
                "<body>" +
                    "<table>" +
                    "<tr><td>1</td><td>2</td><td>3</td><td>4</td><td>5</td></tr>" +
                    "<tr><td>6</td><td>7</td><td>8</td><td>9</td><td>10</td></tr>" +
                    "</table>" +
                "</bod>" +
            "</html>";

    System.out.println("aspose.cells version:" + CellsHelper.getVersion());

    Workbook workbook = new Workbook(new ByteArrayInputStream(html.getBytes()));
    //格式另存
    workbook.save("output.csv", SaveFormat.CSV);
    workbook.save("output.xls", SaveFormat.EXCEL_97_TO_2003);
    workbook.save("output.xlsx", SaveFormat.XLSX);
    workbook.save("output.pdf", SaveFormat.PDF);
}

What is returned after format conversion is the `Workbook` object, which is not the `Workbook` in the API of poi. In fact, the save function can pass the OutputStream stream object, so subsequent analysis can use the Workbook object of poi to parse the OutputStream stream.

2.Other instructions

(1) `aspose.cells` is not open source and free to use. There is a trial version. The result of the trial is that some "Evaluation Warning" warnings are generated;

(2) maven central warehouse https://mvnrepository.com There is only version 8.2.1 of aspose.cells, which is 2015 year version;

(3) Aspose has many products, all of which are commercial paid versions. Common ones include those that operate on Word. Like cells, they are not open source and require commercial authorization. The cells component alone supports different development languages. There are Java, C++, .NET, etc. In addition to the core components, a web version is also provided. It seems to be used as an Excel processing component for the online version of the browser. The official address: Aspose.Cells | Excel Spreadsheet Processing Java Library;

(4) As of today, October 24, 2023, the latest Release version of this component is `aspose-cells-23.10.jar` which was released on October 14, 2023;

3.Use old version

(1) The latest version has only been released for two weeks, and there are no radical (destruction) or solution versions found on the Internet. It is very difficult to read the decompiled and obfuscated code. I look forward to the emergence of a master;

(2) I found a practical learning tutorial from a big guy on gitee. The author studied the 20.7 version of aspose.cells. It is more than 3 years since the latest version was released and there are nearly 40 Release versions. You can refer to: https://gitee .com/evilrule/crack-aspose, if you need the older version, you can check it out and practice it. You can indeed remove the "Evaluation Warning" warning;

(3) It is for learning only, not for commercial use. Please submit the project to gitee

Screenshot description, in case it cannot be found, I tried setLicense and it only triggers once. Usually you can write a tool class and place the calling logic in a static block. ;

4. New version learning

There are many ways to learn. In addition to learning the API usage of components, you can also learn the research spirit of the 20.7 version activation master. So after a series of failed attempts, aspose-cells-23.10.jar was finally activated successfully. The following is learning process:

(1) Refer to the javassist bytecode framework used by the 20.7 version boss. There are related article examples on this site. I have learned a little about this framework;

(2) Follow the direction provided by the boss of version 20.7 and focus on the `com.aspose.cells.License` class. The method isLicenseSet inside can be understood as whether to set the License and modify it to true; the method getSubscriptionExpireDate can be understood as getting the expiration time. Modify it to 2099; method a can see that it is converting the date format and modifying it to the current date;

(3) Since you are using the tool class of the `Workbook` object, change the object method isLicensed to true;

(4) The above attempts all failed, but the final result was successful. The streamlined changes were very, very small. There was no need to adjust the License class. The latest version of the API attempt only verified this article. The example described is to convert html code into four formats: csv, xls, xlsx, and pdf;

(5) This article is mainly a simple introduction to the `aspose.cells` component. Please do not use the relevant content for commercial purposes. If it causes any problems, All have nothing to do with the author of this article (Do not use for commercial purposes, Do not use for commercial purposes, Do not use for commercial purposes);

(6) Welcome to leave messages and exchanges on this site. Finally, attach the code operation renderings. For reference, please refer to the following:

Running effect preview.gif

(Simplified image of the latest version of cells)

Running effect preview - streamlined

(Condensed picture of the latest version of Words)

Some popular science about the non-open source project aspose.cellsWelcome to Chen Dongdong’s personal experience sharing platformicon-default.png?t=N7T8https://www.chendd.cn /blog/article/1716713331426598913.htmlSome popular science about the latest version 23.10 of the non-open source project aspose.wordsWelcome to Chen Dongdong’s personal experience sharing platformicon-default.png?t=N7T8If you have any questions, please leave a message in the original article above. https://www.chendd.cn/blog/article/1721078374100455426.html

Guess you like

Origin blog.csdn.net/haiyangyiba/article/details/134024297