• 体温填报APP--个人14天体温表


    package com.example.tiwen20;

    import androidx.appcompat.app.AppCompatActivity;
    import androidx.core.app.ActivityCompat;

    import android.Manifest;
    import android.app.Activity;
    import android.content.Context;
    import android.content.Intent;
    import android.content.pm.PackageManager;
    import android.net.Uri;
    import android.os.Bundle;
    import android.os.Environment;
    import android.os.StatFs;
    import android.service.controls.actions.FloatAction;
    import android.util.Log;
    import android.view.View;
    import android.widget.Button;
    import android.widget.ListView;
    import android.widget.TextView;
    import android.widget.Toast;

    import java.io.File;
    import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.io.IOException;
    import java.io.InputStream;
    import java.io.OutputStream;
    import java.util.ArrayList;
    import java.util.List;

    import jxl.Workbook;
    import jxl.format.Alignment;
    import jxl.format.Colour;
    import jxl.format.ScriptStyle;
    import jxl.format.UnderlineStyle;
    import jxl.write.Label;
    import jxl.write.WritableCell;
    import jxl.write.WritableCellFormat;
    import jxl.write.WritableFont;
    import jxl.write.WritableSheet;
    import jxl.write.WritableWorkbook;

    public class shengchengbiaoActivity extends AppCompatActivity {
    private UserDB stuDao;
    private TiwenDB wenDao;
    private TiwenBean wenDate;
    private UserBean stuDate;
    private String name;
    private List<TiwenBean> listwendate;
    private List<UserBean> liststudate;
    private Button daochu;
    private Button dakai;
    private Log log;
    private Context context;
    private ListView form_list;
    private final int REQUEST_EXTERNAL_STORAGE = 1;
    private String[] PERMISSIONS_STORAGE = {
    Manifest.permission.READ_EXTERNAL_STORAGE,
    Manifest.permission.WRITE_EXTERNAL_STORAGE };
    @Override
    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_shengchengbiao);
    daochu = (Button)findViewById(R.id.export_button);
    dakai = (Button)findViewById(R.id.open_button);
    Intent intent = getIntent();
    liststudate = new ArrayList<>();
    listwendate = new ArrayList<>();
    name = intent.getStringExtra("name");
    stuDao=new UserDB(this);
    liststudate=stuDao.queryData(name);
    stuDate=liststudate.get(0);
    wenDao=new TiwenDB(this);
    listwendate=wenDao.queryDataFor(name);
    wenDate=listwendate.get(0);
    try {
    if (!Environment.getExternalStorageState().equals(Environment.MEDIA_MOUNTED) &&getAvailableStorage() > 1000000) {
    System.out.println("sd卡不可用");
    }
    else
    {
    System.out.println("sd卡可用");
    }
    File file;
    File dir = new File(Environment.getExternalStorageDirectory().getPath()+"/export");
    if (!dir.exists()) {
    dir.mkdirs();
    }
    file = new File(dir,"excel1.xls");
    System.out.println(Environment.getExternalStorageDirectory());
    WritableWorkbook wwb;
    OutputStream os = new FileOutputStream(file);
    wwb = Workbook.createWorkbook(os);
    //sheet表标题
    WritableSheet wsheet = wwb.createSheet("体温生成表",0);
    //设置A1单元格
    wsheet.mergeCells(0, 0, 6, 0);
    WritableCell cell = wsheet.getWritableCell(0,0);
    WritableFont titleWf = new WritableFont(WritableFont.createFont("仿宋_GB2312"),// 字体
    10,//WritableFont.DEFAULT_POINT_SIZE, // 字号
    WritableFont.BOLD, // 粗体
    false,
    UnderlineStyle.NO_UNDERLINE,
    Colour.BLACK,
    ScriptStyle.NORMAL_SCRIPT);
    WritableCellFormat wcf = new WritableCellFormat(titleWf);
    wcf.setAlignment(Alignment.CENTRE);
    cell.setCellFormat(wcf);
    //填充文字
    Label title =new Label(0,0,"学生14天健康情况登记表");wsheet.addCell(title);
    Label danwei = new Label(0,1,"单位名称:");wsheet.addCell(danwei);
    Label xuexiao = new Label(1,1,"石家庄铁道大学");wsheet.addCell(xuexiao);
    Label name = new Label(0,2,"姓名:");wsheet.addCell(name);
    Label qingkuang = new Label(0,3,"目前健康情况:");wsheet.addCell(qingkuang);
    Label data = new Label(4,1,"填表日期:");wsheet.addCell(data);
    Label id = new Label(4,2,"学号:");wsheet.addCell(id);
    Label phone = new Label(4,3,"手机号:");wsheet.addCell(phone);
    Label data1 = new Label(2,4,"每日体温.健康情况监测(周期14)");wsheet.addCell(data1);
    Label data2 = new Label(0,5,"日期");wsheet.addCell(data2);
    Label tiwen = new Label(1,5,"每日体温℃");wsheet.addCell(tiwen);
    Label qingkuang1 = new Label(2,5,"健康情况");wsheet.addCell(qingkuang1);
    Label didian = new Label(3,5,"当日所在地");wsheet.addCell(didian);
    Label beizhu = new Label(5,5,"备注");wsheet.addCell(beizhu);
    //设置A5
    WritableCell cell1 = wsheet.getWritableCell(0,0);
    WritableFont titleWf1 = new WritableFont(WritableFont.createFont("仿宋_GB2312"),// 字体
    10, // 字号
    WritableFont.BOLD, // 粗体
    false,
    UnderlineStyle.NO_UNDERLINE,
    Colour.BLACK,
    ScriptStyle.NORMAL_SCRIPT);

    WritableCellFormat wcf1 = new WritableCellFormat(titleWf1);
    wcf1.setAlignment(Alignment.CENTRE);
    cell1.setCellFormat(wcf1);
    Label time = new Label(5, 1, wenDate.getTime());wsheet.addCell(time);
    Label name1 = new Label(1, 2, stuDate.getName());wsheet.addCell(name1);
    Label stuId = new Label(5, 2, stuDate.getId());wsheet.addCell(stuId);
    if(Float.valueOf(wenDate.getTiwen().trim()).floatValue()<37.0){ Label wendusitu =
    new Label(1, 3, "良好");wsheet.addCell(wendusitu);
    }else { Label wendusitu =
    new Label(1, 3, "发热");wsheet.addCell(wendusitu);
    } Label phone1 =
    new Label(5, 3, stuDate.getPhone());wsheet.addCell(phone1);
    if(listwendate.size()<14){
    for(int i=0;i<listwendate.size();i++){ Label Time=
    new Label(0,6+i,listwendate.get(i).getTime());wsheet.addCell(Time);
    Label wendu = new Label(1, 6+i, listwendate.get(i).getTiwen().toString());wsheet.addCell(wendu);
    if(Float.valueOf(listwendate.get(i).getTiwen().trim()).floatValue()<37){ Label situation =
    new Label(2, 6+i,"良好");wsheet.addCell(situation);
    }else{ Label situation =
    new Label(2, 6+i,"发热");wsheet.addCell(situation);
    } Label address =
    new Label(3, 6+i,listwendate.get(i).getDidian());wsheet.addCell(address);
    Label special = new Label(5, 6+i,listwendate.get(i).getQingkuang());wsheet.addCell(special);
    } }
    else {
    for(int i=0;i<14;i++){ Label Time=
    new Label(0,6+i,listwendate.get(i).getTime());wsheet.addCell(Time);
    Label wendu = new Label(1, 6+i, listwendate.get(i).getTiwen());wsheet.addCell(wendu);
    if(Float.valueOf(listwendate.get(i).getTiwen().trim()).floatValue()<37){ Label situation =
    new Label(2, 6+i,"良好");wsheet.addCell(situation);
    }else{ Label situation =
    new Label(2, 6+i,"发热");wsheet.addCell(situation);
    } Label address =
    new Label(3, 6+i,listwendate.get(i).getDidian());wsheet.addCell(address);
    Label special = new Label(5, 6+i,listwendate.get(i).getQingkuang());wsheet.addCell(special);
    } } wwb.write()

    ;
    wwb.close();
    if (file.exists()) { System.out.println(
    "文件确实创建了" + file.getAbsolutePath());
    } else { System.out.println(
    "假的,文件就没有创建" + file.getAbsolutePath());
    } }
    catch (Exception e) {
    // TODO: handle exception
    e.printStackTrace();
    } openDir()
    ;
    }
    private static long getAvailableStorage() { StatFs statFs =
    new StatFs(Environment.getExternalStorageDirectory().getPath());
    long blockSize = statFs.getBlockSize();
    long availableBlocks = statFs.getAvailableBlocks();
    long availableSize = blockSize * availableBlocks;
    // Formatter.formatFileSize(context, availableSize);
    return availableSize;
    }
    private void openDir() { Intent intent =
    new Intent("android.intent.action.VIEW");
    intent.addCategory("android.intent.category.DEFAULT");
    intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
    intent.setDataAndType(Uri.fromFile(new File(Environment.getExternalStorageDirectory().getPath()+"/export/excel1.xls")), "application/vnd.ms-excel");
    try { startActivity(intent)
    ;
    } catch (Exception e) { Toast.makeText(
    this, "没有正确打开文件管理器", Toast.LENGTH_SHORT).show();
    } }}


  • 相关阅读:
    CNN做序列标注问题(tensorflow)
    对于梯度消失和梯度爆炸的理解
    LSTM(长短期记忆网络)及其tensorflow代码应用
    Python之禅
    Python namedtuple
    Linux里的2>&1
    PySpark笔记
    平衡二叉树,B树,B+树
    lzo文件操作
    Hadoop的Shell命令
  • 原文地址:https://www.cnblogs.com/huangmouren233/p/14912949.html
Copyright © 2020-2023  润新知