Jxl java. Lang. arrayindexoutofboundsexception: 441 error Solution

Source: Internet
Author: User

 

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.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.