안녕하세요. 아래 문의 남겼는데 시도해보면서 다시 문의 남깁니다.
엑셀에 이미지를 넣으려고 하는데요.
엑셀문서 만들고 이미지 넣는 코드 아래와 같구요... 액티비티 진입시 바로 코드 아래와 같은 로그메세지가 뜹니다. 그리고 엑셀파일 만들기 버튼 누르면 worbook 초기화 하는데부터 오류 나구요.
이 오류 해당 클래스가 없다는 뜻인거같은데....제가 추가한 jar파일에 보면 해당 클래스가 있거든요 ㅠㅠ
참조가 제대로 되지 않는 문제일까요?????? 그런데 라이브러리 수십가지 방법으로 추가해봐도 계속 같은 오류 나네요 ㅠㅠ
도와주세요~~~~~~~~~~
public void boardToExcel(String filePath) {
// create a new workbook
Workbook wb = new XSSFWorkbook();
//Workbook wb = new HSSFWorkbook();
// add picture data to this workbook.
InputStream is = null;
try {
is = new FileInputStream(
"/storage/emulated/0/Gallery/test.jpg");
} catch (FileNotFoundException e1) {
e1.printStackTrace();
}
byte[] bytes = null;
try {
bytes = IOUtils.toByteArray(is);
} catch (IOException e1) {
e1.printStackTrace();
}
int pictureIdx = wb.addPicture(bytes, Workbook.PICTURE_TYPE_JPEG);
try {
is.close();
} catch (IOException e1) {
e1.printStackTrace();
}
CreationHelper helper = wb.getCreationHelper();
// create sheet
Sheet sheet = wb.createSheet();
// Create the drawing patriarch. This is the top level container for all
// shapes.
Drawing drawing = sheet.createDrawingPatriarch();
// add a picture shape
ClientAnchor anchor = helper.createClientAnchor();
// set top-left corner of the picture,
// subsequent call of Picture#resize() will operate relative to it
anchor.setCol1(3);
anchor.setRow1(2);
Picture pict = drawing.createPicture(anchor, pictureIdx);
// auto-size picture relative to its top-left corner
pict.resize();
FileOutputStream fileOut = null;
try {
fileOut = new FileOutputStream(filePath);
} catch (FileNotFoundException e) {
e.printStackTrace();
}
try {
wb.write(fileOut);
} catch (IOException e) {
e.printStackTrace();
}
try {
fileOut.close();
} catch (IOException e) {
e.printStackTrace();
}
}
==============================
11-10 18:03:52.717: E/dalvikvm(22931): Could not find class 'org.apache.poi.xssf.usermodel.XSSFWorkbook', referenced from method com.example.boardtoexcelfinal.MainActivity.boardToExcel
11-10 18:03:52.717: W/dalvikvm(22931): VFY: unable to resolve new-instance 40 (Lorg/apache/poi/xssf/usermodel/XSSFWorkbook;) in Lcom/example/boardtoexcelfinal/MainActivity;
11-10 18:03:52.717: D/dalvikvm(22931): VFY: replacing opcode 0x22 at 0x0002
11-10 18:03:52.717: I/dalvikvm(22931): Could not find method org.apache.poi.xssf.usermodel.XSSFWorkbook.getSheetAt, referenced from method com.example.boardtoexcelfinal.MainActivity.boardToExcel
11-10 18:03:52.717: W/dalvikvm(22931): VFY: unable to resolve virtual method 47: Lorg/apache/poi/xssf/usermodel/XSSFWorkbook;.getSheetAt (I)Lorg/apache/poi/xssf/usermodel/XSSFSheet;
11-10 18:03:52.717: D/dalvikvm(22931): VFY: replacing opcode 0x6e at 0x000e