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());
}
}
Nhẫn phong thủy là gì? Phong thủy là một triết lí trừu tượng và rất khó nắm bắt, theo quan niệm từ tiên tổ cho rằng mọi góc cạnh trong cuộc sống điều ít hoặc nhiều can hệ đến phong thủy từ xây nhà,...
Vòng phong thủy là cái gì? Cách đeo nhẫn đem lại may mắn