마스터Q&A 안드로이드는 안드로이드 개발자들의 질문과 답변을 위한 지식 커뮤니티 사이트입니다. 안드로이드펍에서 운영하고 있습니다. [사용법, 운영진]

엑셀 이미지넣기 다시 질문합니다.(poi)

0 추천

안녕하세요. 아래 문의 남겼는데 시도해보면서 다시 문의 남깁니다.

엑셀에 이미지를 넣으려고 하는데요.

엑셀문서 만들고 이미지 넣는 코드 아래와 같구요... 액티비티 진입시 바로 코드 아래와 같은 로그메세지가 뜹니다. 그리고 엑셀파일 만들기 버튼 누르면 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

 

익명사용자 님이 2015년 11월 10일 질문

답변 달기

· 글에 소스 코드 보기 좋게 넣는 법
· 질문에 대해 추가적인 질문이나 의견이 있으면 답변이 아니라 댓글로 달아주시기 바랍니다.
표시할 이름 (옵션):
개인정보: 당신의 이메일은 이 알림을 보내는데만 사용됩니다.
스팸 차단 검사:
스팸 검사를 다시 받지 않으려면 로그인하거나 혹은 가입 하세요.
...