Iii. Java-related
The reason why the shell program calls the Java program is: the Excel file generated by the Perl script, where the entry URL cannot be decoded to recognize Chinese characters (related to Linux coding, you cannot change the system encoding. Therefore, you must use a Java program to process the Excel files generated by Perl ). For example
Save to the new Excel file.
For the basic operations on reading and writing excel in Java, refer to the most comprehensive explanation of exporting excel in jxl.
Java can read and write Excel files in two ways: org. Apache. Poi and jxl (to import a jar package: jxl. Jar ). I started to use the poi method, but this method handles the total error of the original Excel file:
Java. Lang. runtimeexception: Unexpected record type (Org. Apache. Poi. hssf. Record. hyperlinkrecord)
At org. Apache. Poi. hssf. Record. Aggregates. rowrecordsaggregate. <init> (rowrecordsaggregate. Java: 98)
At org. Apache. Poi. hssf. model. Sheet. <init> (sheet. Java: 203)
At org. Apache. Poi. hssf. model. Sheet. createsheet (sheet. Java: 158)
At org. Apache. Poi. hssf. usermodel. hssfworkbook. <init> (hssfworkbook. Java: 287)
At org. Apache. Poi. hssf. usermodel. hssfworkbook. <init> (hssfworkbook. Java: 201)
At org. Apache. Poi. hssf. usermodel. hssfworkbook. <init> (hssfworkbook. Java: 317)
At org. Apache. Poi. hssf. usermodel. hssfworkbook. <init> (hssfworkbook. Java: 298)
At com. Hudong. Test. testpoi. Read (testpoi. Java: 105)
At com. Hudong. Test. testpoi. Read (testpoi. Java: 79)
At com. Hudong. Test. testpoi. Main (testpoi. Java: 36)
To solve this problem, open the Excel file and click Save when you close it twice. The problem is solved. However, no one asks you to click excel on the server twice each time. Therefore, you can use jxl to process the Excel files generated by Perl.
1. utf8 Decoding of recognizable Chinese characters (Java ):
String temp = http://www.hudong.com/wiki/%E5%8D%95%E6%9B%B2%E5%BE%AA%E7%8E%AF%E7%97%87temp = URLDecoder.decode(temp,"utf-8");
The encoding method is urlencoder. encode ();
2. Read and Write Excel files in Java: (Resources uploaded, downloadable, in my resources)
Decodeexceljxl. Java
Use ARGs [] to directly obtain the parameters passed by the shell script.
Public static void main (string [] ARGs) throws biffexception, ioexception, rowsexceededexception, writeexception {// obtain the Excel table to be processed if (ARGs! = NULL & args. Length = 1) {filepath = ARGs [0];} rewritewithnew (filepath );}