HACKIS - Hacking Internet Security
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Tuyệt Kỹ Đong Giai Chân Kinh (tuyệt Kỹ cua trai)
Đọc dữ liệu từ file excel trong Java EmptyThu Aug 23, 2012 5:38 am by Admin

» Tuyệt kỹ cua giai
Đọc dữ liệu từ file excel trong Java EmptyThu Aug 23, 2012 5:36 am by Admin

» NETCAT.........
Đọc dữ liệu từ file excel trong Java EmptyMon Aug 13, 2012 6:35 am by Admin

» Bảo mật CSDL bằng phương pháp mã hóa.
Đọc dữ liệu từ file excel trong Java EmptyTue Apr 17, 2012 10:04 pm by Admin

» Hàm mã hóa MD5 bằng JavaScript
Đọc dữ liệu từ file excel trong Java EmptyTue Apr 17, 2012 10:03 pm by Admin

» Giá của món quà
Đọc dữ liệu từ file excel trong Java EmptyFri Apr 13, 2012 6:01 am by Admin

» Sẽ chỉ yêu ai?
Đọc dữ liệu từ file excel trong Java EmptyFri Apr 13, 2012 6:01 am by Admin

» Cách đọc bảng chữ cái!
Đọc dữ liệu từ file excel trong Java EmptyThu Apr 12, 2012 10:37 pm by Admin

» Gắn trojan, keylog, virus vào website, forum
Đọc dữ liệu từ file excel trong Java EmptyTue Apr 10, 2012 1:14 am by Admin

Affiliates
free forum


Đọc dữ liệu từ file excel trong Java

Go down

Đọc dữ liệu từ file excel trong Java Empty Đọc dữ liệu từ file excel trong Java

Post  Admin Sun Jun 12, 2011 9:59 am

Bài viết này hướng dẫn bạn cách đọc dữ liệu từ file Excel trong ứng dụng Java như thế nào. Chúng ta cần sử dụng thư viện jxl.jar, tải file về từ địa chỉ:
http://congdongjava.com/thuvien/jxl-2.6.jar
sau đó add vào libary của chương trình
Dưới đây là demo, đọc 1 file xls bằng Java

Code:
import java.io.File;
import java.io.IOException;
import java.util.logging.Level;
import java.util.logging.Logger;
import jxl.Sheet;
import jxl.Workbook;
import jxl.read.biff.BiffException;

/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/

/**
*
* @author Tran Huy
*/
public class docfileexcel {
public static void main(String[] args) {
try {
File file = new File("C:\\demo.xls");
Workbook wb = Workbook.getWorkbook(file);
Sheet sheet = wb.getSheet(0);
int rows = sheet.getRows();
int cols = sheet.getColumns();
for(int row = 0; row < rows; row++) {
for(int col = 0; col < cols; col++) {
System.out.print(sheet.getCell(col, row).getContents()+" ");
}
System.out.println("\n");
}
} catch (Exception ex) {
Logger.getLogger(docfileexcel.class.getName()).log (Level.SEVERE, null, ex);
}

}
}
Admin
Admin
Admin

Tổng số bài gửi : 782
Join date : 2009-08-15

https://hackis.forumvi.com

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum