Προς το περιεχόμενο

Java-WebServices-Excel


tsakonas

Προτεινόμενες αναρτήσεις

Δημοσ.

arxarios sth java kai exw mia ergasia spazokefalia gia noobs like me....prospa8w na doulepwsw me web services. o client prospa8ei na anoiksei ena excel arxeio mesw web services.

o kwdikas pou exw kanei ston client einai:

 

to vala se txt doc...de me afhnei na to valw edw san


Vasika etsi opws einai den einai akrivws web service ka8ws den anoigei to arxeio mesw tou web service.

Mipws 8a mporouse kapoios na voi8isei;

New Text Document.txt

Δημοσ.

package level1;

 

 

public class Level1Client

{

public static void main(String [] args) throws Exception

{

level1.ws.Level1Service service = new level1.ws.Level1ServiceLocator();

level1.ws.Level1 level = service.getlevel1();

Process p =

Runtime.getRuntime().exec("cmd /C C:\\Book.xls");

System.out.println("Well Done");

 

 

}

}

 

 

to interface einai :

 

 

package level1;

 

 

public interface Level1 {

public void main(String[] args) throws Exception ;

}

 

 

to implementation einai:

 

 

package level1;

 

public class Level1Impl implements Level1

{

public void main(String[] args) throws Exception {

Process p =

Runtime.getRuntime().exec("cmd /C C:\\Book.xls");

p.waitFor();

System.out.println("Well Done");

}

}

 

vlepete kana lathos re paides? ti mou ksefeugei?

Δημοσ.

euxaristw gia tin apantisi........de voithise omws...dokimazoume allh prosegisi sto programma....Auto einai ena programma gi ana anoigei ena excel file kai na diavazei ta data. to provlima sauto

to programma einai oti einai se static. Me tin static de mporw na to kanw se web services. Prospaa8oume

na vroume tropo na to kanoume me allo tropo me alli function alla de ta exoume kataferei! kathe idea euprosdekti paidia...euxaristw

 

import java.io.IOException;

import java.io.InputStream;

import java.util.Iterator;

import org.apache.poi.poifs.filesystem.POIFSFileSystem;

import org.apache.poi.hssf.usermodel.HSSFCell;

import org.apache.poi.hssf.usermodel.HSSFSheet;

import org.apache.poi.hssf.usermodel.HSSFWorkbook;

import org.apache.poi.hssf.usermodel.HSSFRow;

 

 

public class excel {

 

public static void main(String[] args) throws Exception{

 

 

 

InputStream input = POIExample.class.getResourceAsStream( "Book1.xls" );

POIFSFileSystem fs = new POIFSFileSystem( input );

HSSFWorkbook wb = new HSSFWorkbook(fs);

HSSFSheet sheet = wb.getSheetAt(0);

 

// Iterate over each row in the sheet

Iterator rows = sheet.rowIterator();

 

 

while( rows.hasNext() ) {

HSSFRow row = (HSSFRow) rows.next();

System.out.println( "Row #" + row.getRowNum() );

 

 

 

// Iterate over each cell in the row and print out the cell's content

Iterator cells = row.cellIterator();

 

 

while( cells.hasNext() ) {

HSSFCell cell = (HSSFCell) cells.next();

System.out.println( "Cell #" + cell.getCellNum() );

switch ( cell.getCellType() ) {

case HSSFCell.CELL_TYPE_NUMERIC:

System.out.println( cell.getNumericCellValue() );

break;

case HSSFCell.CELL_TYPE_STRING:

System.out.println( cell.getStringCellValue() );

break;

default:

System.out.println( "unsuported sell type" );

break;

}

}

}

 

}

 

}

Αρχειοθετημένο

Αυτό το θέμα έχει αρχειοθετηθεί και είναι κλειστό για περαιτέρω απαντήσεις.

  • Δημιουργία νέου...