zoukankan      html  css  js  c++  java
  • 体温上报软件开发

    这是导出栏,

    根据获得的文件路径,

    在手机文件复制并打开,

    可以得到xlsx表格,

    查看录入的信息内容

    路径获取函数:

    public void exportExcel() {

    file = new File(getSDPath(this) + "/Record2");
    makeDir(file);
    ExcelUtils.initExcel(file.toString() + "/14天健康登记表.xlsx");
    fileName = getSDPath(this) + "/Record2/14天健康登记表.xlsx";
    ExcelUtils.writeObjListToExcel(getRecordData(), fileName, this);
    }

    /**
    * 将数据集合 转化成ArrayList<ArrayList<String>>
    * @return
    */
    private ArrayList<ArrayList<String>> getRecordData() {
    recordList = new ArrayList<>();
    for (int i = 0; i <students.size(); i++) {
    temBean student = students.get(i);
    ArrayList<String> beanList = new ArrayList<String>();
    beanList.add(student.getTime());
    beanList.add(student.getAddress());
    beanList.add(student.getTemperature());
    beanList.add(student.getAddition());
    recordList.add(beanList);
    }
    return recordList;
    }

    //获取sd卡地址
    public static String getSDPath(Context context) {
    File sdDir = null;
    boolean sdCardExist = Environment.getExternalStorageState().equals(
    Environment.MEDIA_MOUNTED);// 判断sd卡是否存在

    if (sdCardExist) {
    if (Build.VERSION.SDK_INT>=29){
    //Android10之后
    sdDir = context.getExternalFilesDir(null);
    }else {
    sdDir = Environment.getExternalStorageDirectory();// 获取SD卡根目录

    }
    } else {
    sdDir = Environment.getRootDirectory();// 获取跟目录
    }
    return sdDir.toString();
    }


    public void makeDir(File dir) {
    if (!dir.getParentFile().exists()) {
    makeDir(dir.getParentFile());
    }
    dir.mkdir();
  • 相关阅读:
    js动态生成表格
    My97DatePicker显示时间控件的使用方法
    理解Action,Service和Dao功能(转)
    Myeclipseforspring 10破解
    MySQL常用命令(参考资料,部分改动)
    Struts2---Result(传统Web应用程序与Ajax应用程序的异同)
    正则表达式笔记
    day5.字符串内置函数
    day5.数据类型简介
    day4.变量+程序交互
  • 原文地址:https://www.cnblogs.com/D10304/p/14910397.html
Copyright © 2011-2022 走看看