I am getting 다음과 같은 오류 스레드 " main" idfsysobject. >;; 자바드란g.노클레스데파운더로: org/apache/xmlbeans/XmlObject dell. 러더부k.라이테토렉셀시t.크리티우스푸트피레 (WriteToExcelSheet.java:20) dell. 러더부k.맹메토d.맹 (MainMethod.java:71)
이러한 이유로 인해 내가 생각하고 있지만, 나는 왜 이 가져오는 # 39 이 오류에 대해 온라인 couldn& 찾을 수 없다.
나는 다음과 같은 jar 파일을 포함
poi-3.9-20121203.jar,
poi-excelant-3.9-20121203.jar,
poi-examples-3.9-20121203.jar,
poi-ooxml-3.9-20121203.jar,
poi-ooxml-schemas-3.9-20121203.jar,
poi-scratchpad-3.9-20121203.jar
코드:
public class WriteToExcelSheet {
public static Map < Integer, Object[] > data = new TreeMap < Integer, Object[] > ();
public static void CreateOutPutFile() {
XSSFWorkbook workbook = new XSSFWorkbook();
XSSFSheet sheet = workbook.createSheet("Orderbook Stats");
//This data needs to be written (Object[])
//Iterate over data and write to sheet
Set < Integer > keyset = data.keySet()
int rownum = 0;
for (Integer key: keyset) {
Row row = sheet.createRow(rownum++);
Object[] objArr = data.get(key);
int cellnum = 0;
for (Object obj: objArr) {
Cell cell = row.createCell(cellnum++);
if (obj instanceof String) cell.setCellValue((String) obj);
else if (obj instanceof Integer) cell.setCellValue((Integer) obj);
}
}
try {
//Write the workbook in file system
System.out.println("OutPutStats.xlsx writing..............................");
FileOutputStream out = new FileOutputStream(new File("FileLocation/o.xlxs"));
workbook.write(out);
out.close();
System.out.println("OutPutStats.xlsx written successfully on disk.");
} catch (Exception e) {
e.printStackTrace();
}
}
}
엑셀 파일로 변환할 때 추가 스마르빈스스스스자리 jar, .xlsx 접미어입니다 합니다 , 는 버전 등 xmlbeans-2.3.0.jar '' xxxx
이를 위해 모든 것을 추가했는지 xmlbeans-2.3.0.jar 작동안함 하세프워크부크 스와프 보크부크 대신 jar 추가 후 사용해야 합니다. 예를 들어,
Workbook workbook = new HSSFWorkbook();
Sheet listSheet = workbook.createSheet("Kişi Listesi");
int rowIndex = 0;
for (KayitParam kp : kayitList) {
Row row = listSheet.createRow(rowIndex++);
int cellIndex = 0;
row.createCell(cellIndex++).setCellValue(kp.getAd());
row.createCell(cellIndex++).setCellValue(kp.getSoyad());
row.createCell(cellIndex++).setCellValue(kp.getEposta());
row.createCell(cellIndex++).setCellValue(kp.getCinsiyet());
row.createCell(cellIndex++).setCellValue(kp.getDogumtarihi());
row.createCell(cellIndex++).setCellValue(kp.getTahsil());
}
try {
ByteArrayOutputStream baos = new ByteArrayOutputStream();
workbook.write(baos);
AMedia amedia = new AMedia("Kisiler.xls", "xls",
"application/file", baos.toByteArray());
Filedownload.save(amedia);
baos.close();
} catch (Exception e) {
e.printStackTrace();
}