When you use a jxl package to operate an Excel file, an error occurs when copying a large number of cells. The information is as follows:
1 Java. Lang. arrayindexoutofboundsexception: 441
2 Jxl. Biff. indexmapping. getnewindex (indexmapping. Java: 68 )
3 Jxl. Biff. formattingrecords. rationalize (formattingrecords. Java: 372 )
4 Jxl. Write. Biff. writableworkbookimpl. rationalize (writableworkbookimpl. Java: 727 )
5 Jxl. Write. Biff. writableworkbookimpl. Write (writableworkbookimpl. Java: 489 )
This error took me a lot of time. To avoid it, I tried to split the records in an Excel report into several parts for processing, which was very slow and efficient, it was very annoying. Later, I saw some suggestions on the Internet.Source codeMay be able to better understand it.CodeTo make debugging and tracking clearer, I set the sourceProgramDirectly imported to the Project for debugging. The result shows that this error is caused by formatting records. Java under jxl. Biff. It defines a variable Private Static final int maxformatrecordsindex
= 0x1b9; that is, the maximum number of records is 441. Therefore, whenever the copied cell exceeds the variable value, an error is reported. The solution is to change 0x1b9 to a large value, I changed to 7200, which basically met the requirements. I didn't report this error any more. In the past, when I copied cells and lost cell formats, the problem was completely solved!
Lesson: You must dare to research and question the ready-made and ready-made items, especially open-source ones, because they are all for personal use. Some of them are inevitable, it is not suitable for our own projects. When we find the source code and track it, We can basically solve the problem. In the past, we always felt like we were doing our best, I always think that others' things are correct, and the results lead to problems until now. It is always the best way to practice them in person!
Newworkbook is also called. importsheet (name, newworkbook. getnumberofsheets () + 1, sheet); if the method is a 2007 file edited by 2003, an error is reported for extra columns and rows with borders in the sheet.