Read an Excel Sheet with the Services java Extention [message #1791071] |
Fri, 22 June 2018 11:25 |
Andreas Buchner Messages: 47 Registered: August 2017 |
Member |
|
|
Hi everyone,
I think I have found a bug...
What i try is to read an Excel Sheet with the jxl.java Library.
The Code is quite simple but leads to an disturbance!
public void readExc() throws IOException {
File inputWorkbook = new File("C:\\Users\\buchan4\\desktop\\TestExcelforEclipseImport.xls");
Workbook w = null;
String Value = null;
try {
w = Workbook.getWorkbook(inputWorkbook);
} catch (BiffException e) {
e.printStackTrace();}
Sheet sheet = w.getSheet(0);
Cell cell = sheet.getCell(0,0);
Value = cell.getContents();
JOptionPane.showMessageDialog(null, Value + ", Im called from Services");
}
If I have this peace of code in my Services Class, all of the methodes of the Service stops to work, when I call it from a representation (or the Sirius Interpreter). I know the Code is correct, it works elsewhere.
If I put the try and catch line as a comment, I can call the methods of the Services from the representation or the Interpreter again.
That made me believe, that the Code would not work in the Service at all. But it does. I have created another class, which calls the Methode from the Service.
heres the code of the other class:
public class ReadExcel1 {
public void read() throws IOException {
File inputWorkbook = new File("C:\\Users\\buchan4\\desktop\\TestExcelforEclipseImport.xls");
Workbook w;
String Value = null;
try {
w = Workbook.getWorkbook(inputWorkbook);
Sheet sheet = w.getSheet(0);
Cell cell = sheet.getCell(0,0);
Value = cell.getContents();
System.out.println(Value);
JOptionPane.showMessageDialog(null, Value+ ", Im called from ReadExcel1");
Services s = new Services();
s.readExc();
} catch (BiffException e) {
e.printStackTrace();
}
}
public static void main(String[] args) throws IOException {
ReadExcel1 test = new ReadExcel1();
test.read();
}
}
I dont know exactly where the bug is, but somethings wrong I guess???
If you have better ways to read Excel files, please let me know?
|
|
|
Powered by
FUDForum. Page generated in 0.02970 seconds