Use jxl extract to take the sheet in Excel

Source: Internet
Author: User

When using jxl bench to retrieve the sheet in Excel, it must be noted that there are limits on using the sheet in Excel in jxl bench. Only the sheet in PNG format is supported.

Because the jxl worksheet uses the Excel worksheet to retrieve all the screenshots at a time, and there is a picture collection,

In addition, in many cases, the number of rows in the Excel file is not only the classification type, but also other types. Therefore, you need to record the row index of the sheet in the Excel file, to facilitate the second request

SoProgramUsing the map set to store the row index and the number of dynamic words in the Excel worksheet (that is, stored in a word dataset)

Class readpicture {
Private Map <integer, byte []> map;
Public readpicture (){
Map = new hashmap ();
}
Public map readpicturedata (string excelpath) throws biffexception, ioexception {
// Excel thin Image
Workbook book = Workbook. getworkbook (new file (excelpath ));
// The first worker worksheet object
Sheet sheet = book. getsheet (0 );
// Judge the starting position of the row where the sheet is taken
Cell cell = NULL;
For (INT I = 0; I <sheet. getnumberofimages (); I ++ ){
Image image = sheet. getdrawing (I );
If (image! = NULL ){
// System. Out. println ("image. getrow () --->" + image. getrow ());
Int key = (INT) image. getrow (); // obtain the row index of the shard.
// System. Out. println ("Key --->" + key );
Byte [] imagedata = image. getimagedata (); // obtain the number of characters in the line.
Map. Put (Key, imagedata );
} Else {
Break;
}
}
Return map;
}
}

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.