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());
}
}
Bánh bao - một món ăn tập quán của Việt Nam đã trở thành 1 trong những món ăn phổ biến và được yêu thích không chỉ trong nước mà còn trên quốc tế. Với hương vị mặn mà, đáng chú ý và dễ ăn, bánh bao...
Bí quyết làm thế nào để đại lý bánh bao kỳ lạ thực khách