Hello Capella community,
I’ve just started developing a code using Capella Studio for file reading. I’m following the steps outlined on this site: capella-studio/doc/plugins/org.polarsys.capella.studio.doc/html/extension/tutorials/Create-Addons.md at master · eclipse/capella-studio · GitHub
While developing, I encountered errors in reading an Excel file in this format:
I have successfully downloaded the Apache Poi libraries and integrated them into the Capella Studio library. Here they are:
This file org.apache.poi.ss.usermodel.WorkbookFactory cannot be found by org.polarsys.capella.Excel2Capella_1.0.0.qualifier
If anyone has encountered a similar problem or has suggestions on resolving this specific error, I would be grateful for any assistance or guidance.
I appreciate any help you can provide.
King regards.
Source code :
package org.polarsys.capella.xxxx.handlers;
import org.eclipse.core.commands.ExecutionEvent;
import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.commands.IHandler;
import org.eclipse.core.commands.IHandlerListener;
import java.io.FileInputStream;
import java.io.IOException;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.usermodel.WorkbookFactory;
import org.apache.poi.ss.usermodel.CellType;
public class ImportExcel2Capella implements IHandler {
@Override
public void addHandlerListener(IHandlerListener handlerListener) {
// TODO Auto-generated method stub
}
@Override
public void dispose() {
// TODO Auto-generated method stub
}
@Override
public Object execute(ExecutionEvent event) throws ExecutionException {
// TODO Auto-generated method stub
try (FileInputStream fichierExcel = new FileInputStream("D:/Dev Addon/Excel2Capella.xlsx")) {
Workbook workbook = WorkbookFactory.create(fichierExcel);
Sheet sheet = workbook.getSheetAt(0); // Vous pouvez changer l'index selon la feuille que vous souhaitez lire
for (Row row : sheet) {
for (Cell cell : row) {
if (cell.getCellType() != CellType.BLANK) {
System.out.print(cell.toString() + "\t");
}
}
System.out.println();
}
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
@Override
public boolean isEnabled() {
// TODO Auto-generated method stub
return true;
}
@Override
public boolean isHandled() {
// TODO Auto-generated method stub
return false;
}
@Override
public void removeHandlerListener(IHandlerListener handlerListener) {
// TODO Auto-generated method stub
}
public static void main(String[] args) {
// TODO Auto-generated method stub
}
}