2021/3/16

1.今日收获内容
将写的内容放入表格中

 private void exportExcel(Context context) {

        String path = getExternalFilesDir("test3").getPath();
        File file = new File(path);
        if (!file.exists()) {
            file.mkdirs();
        }
        File files = new File(file.getPath()+"/"+"text3.xls");
        if (!files.exists()) {// 文件存在返回false
            try {
                files.createNewFile();//创建文件

            } catch (IOException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }
        }
        Toast.makeText(MainActivity.this, "存储到"+files.getPath(), Toast.LENGTH_SHORT).show();
        initExcel(files);
    }//创建表格

 建立表格。

private void openDir() {

File file = new File(filePath);
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
intent.setType("/test3");
intent.addCategory(Intent.CATEGORY_OPENABLE);
intent.setDataAndType(Uri.fromFile(file), "files/test3/text3.xls");
try {
startActivity(intent);
} catch (Exception e) {
Toast.makeText(this, "没有正确打开文件管理器", Toast.LENGTH_SHORT).show();
}
}

设定位置


2.遇到的问题
开始找不到

3.明天目标

表格设计

原文地址:https://www.cnblogs.com/qiangini/p/14905814.html