Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.

SWT i Excel, upisivanje i citanje

[es] :: Java :: SWT i Excel, upisivanje i citanje

[ Pregleda: 3803 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Autor

Pretraga teme: Traži
Markiranje Štampanje RSS

mvasicdo
Mladen Vasic
Doboj

Član broj: 104294
Poruke: 226
*.teol.net.



Profil

icon SWT i Excel, upisivanje i citanje19.12.2007. u 13:53 - pre 199 meseci
Da li je moguci iz SWT aplikacije tj. iz Tabele upisati podatke u Excel fajl?

1. interesuje me upis u postojeci fajl, tako da mu ja odredim od koje celije ide koja kolona
2. u novi fajl.
3. otvaranje postojeceg excel fajla u nekoj SWT kontroli, da li postoji ta kontrola
 
Odgovor na temu

Dejan Lozanovic
Dejan Lozanovic
Beograd

Član broj: 691
Poruke: 2325
*.dynamic.sbb.co.yu.

Jabber: null@elitesecurity.org
Sajt: speedy-order.com


+75 Profil

icon Re: SWT i Excel, upisivanje i citanje20.12.2007. u 13:19 - pre 199 meseci
Pogledaj http://poi.apache.org/ ova biblioteka ti omogucava manipulaciju sa excel fajlovima.
 
Odgovor na temu

toroman
Srećko Toroman
www.wowd.com
Beograd / Banja Luka

Član broj: 52673
Poruke: 159
91.150.102.*

Sajt: toroman.wordpress.com


Profil

icon Re: SWT i Excel, upisivanje i citanje23.12.2007. u 19:19 - pre 198 meseci
Hm, ostalo je nedorečeno kako posle otvoriti Excel fajl unutar SWT aplikacije. Pa, najlakše pomoću OLE frejma.
Programeri su odgovorili na Hamletovo pitanje "Biti il ne biti?" :
0x2B | ~0x2B = 0xFF
(kao ono - ff - teško pitanje!)
 
Odgovor na temu

mvasicdo
Mladen Vasic
Doboj

Član broj: 104294
Poruke: 226
*.teol.net.



Profil

icon Re: SWT i Excel, upisivanje i citanje10.01.2008. u 09:20 - pre 198 meseci
Probao sam i nije lose, ali desava mi se jedan problem:

Kada hocu da izvrsim formulu u odredjenoj celiji dobijem ovu gresku:

Error: ) Expected
Exception in thread "main" java.lang.RuntimeException: Cannot Parse, sorry : ) Expected @ 18 [Formula String was: 'PRODUCT(A1*(B1/2)%)']
at org.apache.poi.hssf.model.FormulaParser.Abort(FormulaParser.java:114)
at org.apache.poi.hssf.model.FormulaParser.Expected(FormulaParser.java:121)
at org.apache.poi.hssf.model.FormulaParser.Match(FormulaParser.java:181)
at org.apache.poi.hssf.model.FormulaParser.function(FormulaParser.java:342)
at org.apache.poi.hssf.model.FormulaParser.Ident(FormulaParser.java:280)
at org.apache.poi.hssf.model.FormulaParser.Factor(FormulaParser.java:505)
at org.apache.poi.hssf.model.FormulaParser.Term(FormulaParser.java:606)
at org.apache.poi.hssf.model.FormulaParser.Expression(FormulaParser.java:654)
at org.apache.poi.hssf.model.FormulaParser.parse(FormulaParser.java:758)
at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.internalEvaluate(HSSFFormulaEvaluator.java:296)
at org.apache.poi.hssf.usermodel.HSSFFormulaEvaluator.evaluateInCell(HSSFFormulaEvaluator.java:223)
at Test.<init>(Test.java:37)
at Test.main(Test.java:74)

Zbog cega se ovo desava.
Evo i dio koda koji koristim:

FileInputStream fis=null;
HSSFWorkbook wb=null;
HSSFSheet sheet=null;
try{
fis = new FileInputStream("C:/test.xls");
wb = new HSSFWorkbook(fis);

sheet = wb.getSheetAt(0);
}catch(Exception e){}
// suppose your formula is in B3

HSSFRow row = sheet.getRow((short)0);
HSSFCell cell1 = row.getCell((short)0);
cell1.setCellValue(2.80f);
HSSFCell cell2 = row.getCell((short)1);
cell2.setCellValue(6.20f);
HSSFCell cell = row.getCell((short)2);

HSSFFormulaEvaluator evaluator = new HSSFFormulaEvaluator(sheet, wb);
evaluator.setCurrentRow(row);
if (cell!=null) {
switch (evaluator.evaluateInCell(cell).getCellType()) {
case HSSFCell.CELL_TYPE_BOOLEAN:
System.out.println(cell.getBooleanCellValue());
break;
case HSSFCell.CELL_TYPE_NUMERIC:
System.out.println(cell.getNumericCellValue());
break;
case HSSFCell.CELL_TYPE_STRING:
System.out.println(cell.getStringCellValue());
break;
case HSSFCell.CELL_TYPE_BLANK:
break;
case HSSFCell.CELL_TYPE_ERROR:
System.out.println(cell.getErrorCellValue());
break;

// CELL_TYPE_FORMULA will never occur
case HSSFCell.CELL_TYPE_FORMULA:
break;
}
}


try{
FileOutputStream fileOut = new FileOutputStream("C:/test.xls");
wb.write(fileOut);
fileOut.close();
}catch(Exception e){

}
 
Odgovor na temu

[es] :: Java :: SWT i Excel, upisivanje i citanje

[ Pregleda: 3803 | Odgovora: 3 ] > FB > Twit

Postavi temu Odgovori

Navigacija
Lista poslednjih: 16, 32, 64, 128 poruka.