Kết quả 1 đến 2 của 2
  1. #1
    Ngày tham gia
    Mar 2015
    Bài viết
    0

    đọc file execl từ thẻ nhớ.

    mình có một file "myfile.xls" trong thẻ nhớ. vậy mình làm cách nào hay dung libs nào để đọc được file này. giúp mình với.

    mình lên google thì có đoạn code này nhưng khi chạy thì nó báo không tìm thấy file.



    Mã nguồn PHP:
    [color=#000000]
    string path [/color][color=#007700]= [/color][color=#0000bb]environment[/color][color=#007700].[/color][color=#0000bb]getexternalstoragedirectory[/color][color=#007700]().[/color][color=#0000bb]getabsolutepath[/color][color=#007700]() + [/color][color=#dd0000]"/myfile.xls"[/color][color=#007700]; [/color][color=#0000bb]init[/color][color=#007700]([/color][color=#0000bb]path[/color][color=#007700]); [/color] 
    Mã:
    public void init(string filepath) {
    // todo auto-generated method stub
    fileinputstream fs = null;
    try{
    fs = new fileinputstream(new file(filepath));
    contentreading(fs);
    }catch(exception e){
    e.printstacktrace();
    }
    }	
    public void contentreading(inputstream fileinputstream){
    workbooksettings ws = null;
    workbook workbook = null;
    sheet s = null;
    cell rowdata[] = null;
    int rowcount = '0';
    int columncont = '0';
    int totalsheet = '0';
     
    try{
    ws = new workbooksettings();
    ws.setlocale(new locale("en", "en"));
    workbook = workbook.getworkbook(fileinputstream);
     
    totalsheet = workbook.getnumberofsheets();
     
    if(totalsheet > 0){
    for(int j =0; j < totalsheet; j++){
    system.out.println("sheet name: " + workbook.getsheet(j).getname());
    }
    }
    sheet sheet = workbook.getsheet(0);
    			// get number row and col contain data
    			int rows = sheet.getrows();
    			int cols = sheet.getcolumns();
     
    			system.out.println("data in file:");
    			// read data in each cell
    			for (int row = 0; row < rows; row++) {
    				for (int col = 0; col < cols; col++) {
    					cell cell = sheet.getcell(col, row);
    					system.out.print(cell.getcontents() + "\t");
    				}
    				system.out.println("
    ");
    			}
    			// close
    			workbook.close();
    } catch (biffexception e) {
    			system.out.println("file not found
    " + e.tostring());
    		} catch (ioexception e) {
    			system.out.println("file not found
    " + e.tostring());
    		}
     
    }

  2. #2
    Ngày tham gia
    Apr 2016
    Bài viết
    0
    không ai giúp mình à.

Quyền viết bài

  • Bạn Không thể gửi Chủ đề mới
  • Bạn Không thể Gửi trả lời
  • Bạn Không thể Gửi file đính kèm
  • Bạn Không thể Sửa bài viết của mình
  •