java - Getting error "Your InputStream was neither an OLE2 stream, nor an OOXML stream or you haven't provide the poi-ooxml*.jar in the classpath/modulepath"
问题描述
I have a problem. I wrote a little program for a friend. I read a .xlsx-file and update this. In the IDE it works well. But if i build a .jar and execute it, then i get the error "Your InputStream was neither an OLE2 stream, nor an OOXML stream or you haven't provide the poi-ooxml*.jar in the classpath/modulepath".
There are abstracts of my code:
//Import Excel
public static ImportDaten importExcel() throws IOException {
ImportDaten importDaten = new ImportDaten();
java.util.List<Kunde> kunden = new ArrayList<>();
List<Artikel> artikelList = new ArrayList<>();
DataFormatter dataFormatter = new DataFormatter();
File inputWorkbook = new File("C:/Users/jboeh/OneDrive/Desktop/stammdaten.xlsx");
Workbook workbook = WorkbookFactory.create(inputWorkbook);
//Rechnungsnummer einlesen
Sheet indexSheet = workbook.getSheet("Index");
//read data
workbook.close();
importDaten.setKunden(kunden);
importDaten.setArtikelList(artikelList);
return importDaten;
}
public static void exportExcel() throws IOException {
FileInputStream inputStream = new FileInputStream(new File("C:/Users/jboeh/OneDrive/Desktop/stammdaten.xlsx"));
Workbook workbook = WorkbookFactory.create(inputStream);
Sheet sheetIndex = workbook.getSheet("Index");
Cell zelleRechNr = sheetIndex.getRow(0).createCell(1);
zelleRechNr.setCellValue(rechnung.getRechnungsnr());
Sheet sheetRechnung = workbook.getSheet("Rechnung");
Cell zelleRechnung;
//write Data
inputStream.close();
FileOutputStream outputStream = new FileOutputStream("C:/Users/jboeh/OneDrive/Desktop/stammdaten.xlsx");
workbook.write(outputStream);
workbook.close();
outputStream.close();
}
I hope somebody can help me.
Thanks
Mira
解决方案
推荐阅读
- android - 如何在 Android 上使用 FirebaseUI 进行帐户链接?
- c++ - 在 OpenGL 中为自由类型设置模型矩阵时类似笔的行为
- python - Pipenv 无法安装任何软件包
- python - 将多个用户配置文件链接在一起
- reporting-services - 基于 Getdate() 函数的 SSRS 报告
- python - 在 (Py)Spark DataFrame 中映射值
- c# - 拖放异常。桌面对象
- android - 如何在xml代码中调用finish()
- firebase - Firestore 查询仅需要的字段 (Firebase)
- angular - 如何在 Angular 中清空组件属性,同时保留其类型定义?