android 实现excel的导出,没有报错,但在目标文件下,找不到应该导出的表

//导出
private void exportDataToExcel() {
ExportThread eThread = new ExportThread(this, excelFileName, new OnExcelReadWriteSuccess() {
@Override
public void onError(Exception e) {

        }
        @Override
        public void onReadSuccess(ArrayList<SmsData> readList) {

        }
        @Override
        public void onWriteSuccess() {
            String exportpath=Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+"tongxunlu.xls";
            try{
                WritableWorkbook wb= Workbook.createWorkbook(new File(exportpath));
                WritableSheet ws=wb.createSheet("sheet",0);
                Label label=new Label(0,0,"name");
                Label label2=new Label(1,0,"phone");
                Label label3=new Label(2,0,"msg");
                Label label4=new Label(3,0,"issend");
                ws.addCell(label);
                ws.addCell(label2);
                ws.addCell(label3);
                ws.addCell(label4);
                for(int i=1;i<lists.size()+1;i++){
                    ws.addCell(new Label(
                            0,i,lists.get(i-1).getName()));
                    ws.addCell(new Label(1,i,lists.get(i-1).getPhone()));
                    ws.addCell(new Label(2,i,lists.get(i-1).getSms()));
                    if(lists.get(i-1).isSent()){
                        ws.addCell(new Label(3,i,"1"));
                    }else {
                        ws.addCell(new Label(3,i,"0"));
                    }
                }
                wb.write();
                wb.close();
                Toast.makeText(MainActivity.this,"导出成功"+exportpath,Toast.LENGTH_SHORT).show();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }


    });

}

1个回答

调试输出下
String exportpath=Environment.getExternalStorageDirectory().getAbsolutePath()+File.separator+"tongxunlu.xls";
这个路径对不对

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问
相关内容推荐