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;
}
}