精华内容
下载资源
问答
  • android 导出Excel列表

    2021-09-09 09:06:35
    一、android导出Excel使用什么库 二、使用步骤 1.封装一个Utils 2.使用方法 总结 前言 本文主要是针对列表数据导出excel模板代码 提示:以下是本篇文章正文内容,下面案例可供参考 一、android导出...

    提示:文章写完后,目录可以自动生成,如何生成可参考右边的帮助文档


    前言

    本文主要是针对列表数据导出excel模板代码


    提示:以下是本篇文章正文内容,下面案例可供参考

    一、android导出Excel使用什么库

    implementation 'net.sourceforge.jexcelapi:jxl:2.6.12'

    二、使用步骤

    1.封装一个Utils

    代码如下(示例):

    public class ExcelUtil {
    
        private static WritableFont arial14font = null;
    
        private static WritableCellFormat arial14format = null;
        private static WritableFont arial10font = null;
        private static WritableCellFormat arial10format = null;
        private static WritableFont arial12font = null;
        private static WritableCellFormat arial12format = null;
        private final static String UTF8_ENCODING = "UTF-8";
    
    
        /**
         * 单元格的格式设置 字体大小 颜色 对齐方式、背景颜色等...
         */
        private static void format() {
            try {
                arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);
                arial14font.setColour(Colour.LIGHT_BLUE);
                arial14format = new WritableCellFormat(arial14font);
                arial14format.setAlignment(jxl.format.Alignment.CENTRE);
                arial14format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
                arial14format.setBackground(Colour.VERY_LIGHT_YELLOW);
    
                arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);
                arial10format = new WritableCellFormat(arial10font);
                arial10format.setAlignment(jxl.format.Alignment.CENTRE);
                arial10format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
                arial10format.setBackground(Colour.GRAY_25);
    
                arial12font = new WritableFont(WritableFont.ARIAL, 10);
                arial12format = new WritableCellFormat(arial12font);
                //对齐格式
                arial10format.setAlignment(jxl.format.Alignment.CENTRE);
                //设置边框
                arial12format.setBorder(jxl.format.Border.ALL, jxl.format.BorderLineStyle.THIN);
    
            } catch (WriteException e) {
                e.printStackTrace();
            }
        }
    
    
        /**
         * 初始化Excel表格
         *
         * @param filePath  存放excel文件的路径(path/demo.xls)
         * @param sheetName Excel表格的表名
         * @param colName   excel中包含的列名(可以有多个)
         */
        public static void initExcel(String filePath, String sheetName, String[] colName) {
            format();
            WritableWorkbook workbook = null;
            try {
                File file = new File(filePath);
                if (!file.exists()) {
                    file.createNewFile();
                } else {
                    return;
                }
                workbook = Workbook.createWorkbook(file);
                //设置表格的名字
                WritableSheet sheet = workbook.createSheet(sheetName, 0);
                //创建标题栏
                sheet.addCell((WritableCell) new Label(0, 0, filePath, arial14format));
                for (int col = 0; col < colName.length; col++) {
                    sheet.addCell(new Label(col, 0, colName[col], arial10format));
                }
                //设置行高
                sheet.setRowView(0, 340);
                workbook.write();
            } catch (Exception e) {
                e.printStackTrace();
            } finally {
                if (workbook != null) {
                    try {
                        workbook.close();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }
        }
    
        /**
         * 将制定类型的List写入Excel中
         *
         * @param objList  待写入的list
         * @param fileName
         * @param mContext
         * @param <T>
         */
        @SuppressWarnings("unchecked")
        public static <T> void writeObjListToExcel(List<T> objList, String fileName, Context mContext) {
            if (objList != null && objList.size() > 0) {
                WritableWorkbook writebook = null;
                InputStream in = null;
                try {
                    WorkbookSettings setEncode = new WorkbookSettings();
                    setEncode.setEncoding(UTF8_ENCODING);
    
                    in = new FileInputStream(new File(fileName));
                    Workbook workbook = Workbook.getWorkbook(in);
                    writebook = Workbook.createWorkbook(new File(fileName), workbook);
                    WritableSheet sheet = writebook.getSheet(0);
    
                    for (int j = 0; j < objList.size(); j++) {
                        StandingBookTable demoBean = (StandingBookTable) objList.get(j);
                        List<String> list = new ArrayList<>();
                        list.add(demoBean.cabinetChildNum + "号柜");
                        list.add(demoBean.userName);
                        if (demoBean.returnBorrow == 1) {
                            list.add("归还");
                        } else {
                            list.add("借出");
                        }
                        list.add(demoBean.articleTypeName);
                        list.add(demoBean.operateTime);
                        list.add(demoBean.articleEpcNum);
    
                        for (int i = 0; i < list.size(); i++) {
                            sheet.addCell(new Label(i, j + 1, list.get(i), arial12format));
                            if (list.get(i).length() <= 4) {
                                //设置列宽
                                sheet.setColumnView(i, list.get(i).length() + 8);
                            } else {
                                //设置列宽
                                sheet.setColumnView(i, list.get(i).length() + 5);
                            }
                        }
                        //设置行高
                        sheet.setRowView(j + 1, 350);
                    }
    
                    writebook.write();
                    workbook.close();
                    LogUtil.e("导出Excel成功");
                } catch (Exception e) {
                    e.printStackTrace();
                } finally {
                    if (writebook != null) {
                        try {
                            writebook.close();
                        } catch (Exception e) {
                            e.printStackTrace();
                        }
    
                    }
                    if (in != null) {
                        try {
                            in.close();
                        } catch (IOException e) {
                            e.printStackTrace();
                        }
                    }
                }
    
            }
        }
    
    
    }

    2.使用方法

    代码如下(示例):

    private String filePath = "/sdcard/AndroidExcel";
    
    public void OninitExcel(View view) {
        EsCabinApp.threadPool.submit(new Runnable() {
            @Override
            public void run() {
                File file = new File(filePath);
                if (!file.exists()) {
                    file.mkdirs();
                }
                String excelFileName = "/台账信息.xls";
                String[] title = {"柜子号", "操作人姓名", "使用状态", "物品类型", "操作时间", "射频标签"};
                String sheetName = "demoSheetName";
                standingBookTables = new ArrayList<>();
                standingBookTables = EsCabinApp.standingBookDao.queryBookAll();
                String filePaths = filePath + excelFileName;
                ExcelUtil.initExcel(filePaths, sheetName, title);
                ExcelUtil.writeObjListToExcel(standingBookTables, filePaths, mActivity);
                EsCabinApp.debugShowToast("导出Excel成功");
            }
        });
    
    }

    该处使用的url网络请求的数据。


    总结

    本文仅仅简单介绍了android导出Excel的代码使用,而导出Excel里面包含了很多读写操作有兴趣可以更深入了解一下。

    展开全文
  • 这是一个导出 excel表格的功能 从创建数据库 到导出表格到文件管理package com.ldm.familybill;import java.io.File;import java.text.SimpleDateFormat;import java.util.ArrayList;import java.util.Date;import ...

    这是一个导出 excel表格的功能 从创建数据库 到导出表格到文件管理

    package com.ldm.familybill;

    import java.io.File;

    import java.text.SimpleDateFormat;

    import java.util.ArrayList;

    import java.util.Date;

    import android.annotation.SuppressLint;

    import android.app.Activity;

    import android.content.ContentValues;

    import android.database.Cursor;

    import android.os.Bundle;

    import android.os.Environment;

    import android.text.TextUtils;

    import android.view.View;

    import android.view.View.OnClickListener;

    import android.widget.Button;

    import android.widget.EditText;

    import android.widget.Toast;

    import com.ldm.db.DBHelper;

    import com.ldm.excel.ExcelUtils;

    @SuppressLint("SimpleDateFormat")

    public class MainActivity extends Activity implements OnClickListener {

    private EditText mFoodEdt;

    private EditText mArticlesEdt;

    private EditText mTrafficEdt;

    private EditText mTravelEdt;

    private EditText mClothesEdt;

    private EditText mDoctorEdt;

    private EditText mRenQingEdt;

    private EditText mBabyEdt;

    private EditText mLiveEdt;

    private EditText mOtherEdt;

    private EditText mRemarkEdt;

    private Button mSaveBtn;

    private File file;

    private String[] title = { "家庭账务记录" ,"事物支出", "日用品项", "交通话费", "旅行出行", "穿着支出", "医疗保健", "人情客往", "包包专项", "户租水电", "其他支出", "备注说明"};

    private String[] saveData;

    private DBHelper mDbHelper;

    private ArrayList>bill2List;

    @Override

    protected void onCreate(Bundle savedInstanceState) {

    super.onCreate(savedInstanceState);

    setContentView(R.layout.activity_main);

    findViewsById();

    mDbHelper = new DBHelper(this);

    mDbHelper.open();

    bill2List=new ArrayList>();

    }

    private void findViewsById() {

    mFoodEdt = (EditText) findViewById(R.id.family_bill_food_edt);

    mArticlesEdt = (EditText) findViewById(R.id.family_bill_articles_edt);

    mTrafficEdt = (EditText) findViewById(R.id.family_bill_traffic_edt);

    mTravelEdt = (EditText) findViewById(R.id.family_bill_travel_edt);

    mClothesEdt = (EditText) findViewById(R.id.family_bill_clothes_edt);

    mDoctorEdt = (EditText) findViewById(R.id.family_bill_doctor_edt);

    mRenQingEdt = (EditText) findViewById(R.id.family_bill_laiwang_edt);

    mBabyEdt = (EditText) findViewById(R.id.family_bill_baby_edt);

    mLiveEdt = (EditText) findViewById(R.id.family_bill_live_edt);

    mOtherEdt = (EditText) findViewById(R.id.family_bill_other_edt);

    mRemarkEdt = (EditText) findViewById(R.id.family_bill_remark_edt);

    mSaveBtn = (Button) findViewById(R.id.family_bill_save);

    mSaveBtn.setOnClickListener(this);

    }

    @Override

    public void onClick(View v) {

    if (v.getId() == R.id.family_bill_save) {

    saveData = new String[] { new SimpleDateFormat("yyyy-MM-dd").format(new Date()), mFoodEdt.getText().toString().trim(), mArticlesEdt.getText().toString().trim(), mTrafficEdt.getText().toString().trim(), mTravelEdt.getText().toString().trim(), mClothesEdt.getText().toString().trim(), mDoctorEdt.getText().toString().trim(), mRenQingEdt.getText().toString().trim(), mBabyEdt.getText().toString().trim(), mLiveEdt.getText().toString().trim(), mOtherEdt.getText().toString().trim(), mRemarkEdt.getText().toString().trim() };

    if (canSave(saveData)) {

    ContentValues values = new ContentValues();

    values.put("time", new SimpleDateFormat("yyyy-MM-dd").format(new Date()));

    values.put("food", mFoodEdt.getText().toString());

    values.put("use", mArticlesEdt.getText().toString());

    values.put("traffic", mTrafficEdt.getText().toString());

    values.put("travel", mTravelEdt.getText().toString());

    values.put("clothes", mClothesEdt.getText().toString());

    values.put("doctor", mDoctorEdt.getText().toString());

    values.put("laiwang", mRenQingEdt.getText().toString());

    values.put("baby", mBabyEdt.getText().toString());

    values.put("live", mLiveEdt.getText().toString());

    values.put("other", mOtherEdt.getText().toString());

    values.put("remark", mRemarkEdt.getText().toString());

    long insert = mDbHelper.insert("family_bill", values);

    if (insert > 0) {

    initData();

    }

    }

    else {

    Toast.makeText(this, "不发送", Toast.LENGTH_SHORT).show();

    }

    }

    }

    @SuppressLint("SimpleDateFormat")

    public void initData() {

    file = new File(getSDPath() "/Family");

    makeDir(file);

    ExcelUtils.initExcel(file.toString() "/客户财务.xls", title);

    ExcelUtils.writeObjListToExcel(getBillData(), getSDPath() "/Family/客户财务.xls", this);

    }

    private ArrayList> getBillData() {

    Cursor mCrusor = mDbHelper.exeSql("select * from family_bill");

    while (mCrusor.moveToNext()) {

    ArrayList beanList=new ArrayList();

    beanList.add(mCrusor.getString(1));

    beanList.add(mCrusor.getString(2));

    beanList.add(mCrusor.getString(3));

    beanList.add(mCrusor.getString(4));

    beanList.add(mCrusor.getString(5));

    beanList.add(mCrusor.getString(6));

    beanList.add(mCrusor.getString(7));

    beanList.add(mCrusor.getString(8));

    beanList.add(mCrusor.getString(9));

    beanList.add(mCrusor.getString(10));

    beanList.add(mCrusor.getString(11));

    beanList.add(mCrusor.getString(12));

    bill2List.add(beanList);

    }

    mCrusor.close();

    return bill2List;

    }

    public static void makeDir(File dir) {

    if (!dir.getParentFile().exists()) {

    makeDir(dir.getParentFile());

    }

    dir.mkdir();

    }

    public String getSDPath() {

    File sdDir = null;

    boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

    if (sdCardExist) {

    sdDir = Environment.getExternalStorageDirectory();

    }

    String dir = sdDir.toString();

    return dir;

    }

    private boolean canSave(String[] data) {

    boolean isOk = false;

    for (int i = 0; i < data.length; i ) {

    if (i > 0 && i < data.length) {

    if (!TextUtils.isEmpty(data[i])) {

    isOk = true;

    }

    }

    }

    return isOk;

    }

    }

    资源下载此资源下载价格为3D币,请先登录

    资源文件列表

    familybill/.classpath , 475

    familybill/.project , 846

    familybill/.settings/org.eclipse.core.resources.prefs , 115

    familybill/.settings/org.eclipse.jdt.core.prefs , 177

    familybill/AndroidManifest.xml , 916

    familybill/bin/AndroidManifest.xml , 916

    familybill/bin/classes/com/ldm/db/DBHelper.class , 2943

    familybill/bin/classes/com/ldm/excel/CreateExcel.class , 2445

    familybill/bin/classes/com/ldm/excel/ExcelUtils.class , 6777

    familybill/bin/classes/com/ldm/excel/SaveToExcel.class , 12035

    familybill/bin/classes/com/ldm/familybill/BuildConfig.class , 345

    familybill/bin/classes/com/ldm/familybill/MainActivity.class , 6618

    familybill/bin/classes/com/ldm/familybill/R$attr.class , 340

    familybill/bin/classes/com/ldm/familybill/R$dimen.class , 461

    familybill/bin/classes/com/ldm/familybill/R$drawable.class , 537

    familybill/bin/classes/com/ldm/familybill/R$id.class , 1397

    familybill/bin/classes/com/ldm/familybill/R$layout.class , 403

    familybill/bin/classes/com/ldm/familybill/R$menu.class , 388

    familybill/bin/classes/com/ldm/familybill/R$string.class , 512

    familybill/bin/classes/com/ldm/familybill/R$style.class , 431

    familybill/bin/classes/com/ldm/familybill/R.class , 673

    familybill/bin/jarlist.cache , 120

    familybill/gen/com/ldm/familybill/BuildConfig.java , 160

    familybill/gen/com/ldm/familybill/R.java , 4367

    familybill/ic_launcher-web.png , 51394

    familybill/libs/android-support-v4.jar , 995624

    familybill/libs/jxl.jar , 704543

    familybill/proguard-project.txt , 781

    familybill/project.properties , 563

    familybill/res/drawable/common_btn_selector.xml , 370

    familybill/res/drawable-hdpi/button_enable_false_bg.9.png , 259

    familybill/res/drawable-hdpi/common_btn_normal.9.png , 337

    familybill/res/drawable-hdpi/ic_launcher.png , 7658

    familybill/res/drawable-mdpi/ic_launcher.png , 3777

    familybill/res/drawable-xhdpi/ic_launcher.png , 12516

    familybill/res/drawable-xxhdpi/ic_launcher.png , 24777

    familybill/res/layout/activity_main.xml , 18323

    familybill/res/menu/main.xml , 368

    familybill/res/values/dimens.xml , 220

    familybill/res/values/strings.xml , 292

    familybill/res/values/styles.xml , 697

    familybill/res/values-v11/styles.xml , 334

    familybill/res/values-v14/styles.xml , 391

    familybill/res/values-w820dp/dimens.xml , 381

    familybill/src/com/ldm/db/DBHelper.java , 2088

    familybill/src/com/ldm/excel/CreateExcel.java , 1921

    familybill/src/com/ldm/excel/ExcelUtils.java , 4636

    familybill/src/com/ldm/excel/SaveToExcel.java , 15049

    familybill/src/com/ldm/familybill/MainActivity.java , 6034

    展开全文
  • 释放双眼,带上耳机,听听看~!我们调试 App 的时候有时候要去除应用下 data/data/ ...首先打开 Android studio 的 Terminal 界面,或者打开命令行,切换到项目的目录下;然后依次执行下面的命令$ adb shell #执行a...

    释放双眼,带上耳机,听听看~!

    我们调试 App 的时候有时候要去除应用下 data/data/ 的文件,之前我都是运行在虚拟机上,然后再取出数据。今天发现一个好的方法,可以在真机上(不用 root )直接去除 data/data/ 下的数据。

    首先打开 Android studio 的 Terminal 界面,或者打开命令行,切换到项目的目录下;

    然后依次执行下面的命令

    $ adb shell #执行adb shell命令连接手机设备

    $ run-as com.packagename #执行run-as命令切换当前用户,这里输入你应用的包名

    $ pwd #定位当前文件位置

    $ ls #查看当前文件夹下的文件

    $ cat databases/xx.db > /sdcard/xx.db #使用cat命令导出需要的文件(xx.db)到sd卡

    然后你就可以看到你需要的文件输出到手机的 sdcard 指定位置,移动到电脑,就可以查看了。

    HWVIE:/ $ run-as com.component.fx.plugin_toutiao

    HWVIE:/data/data/com.component.fx.plugin_toutiao $ ls

    cache databases files shared_prefs

    d databases/ <

    HWVIE:/data/data/com.component.fx.plugin_toutiao/databases $ ls

    TouTiao TouTiao-journal

    HWVIE:/data/data/com.component.fx.plugin_toutiao/databases $ cat TouTiao > /sdcard/TouTiao

    第二种方法

    adb shell

    run-as packageName

    cd

    dd if=$fileName of=/sdcard/$fileName

    adb shell 然后:

    HWVIE:/ $ run-as com.component.fx.plugin_toutiao

    HWVIE:/data/data/com.component.fx.plugin_toutiao $ ls

    cache databases files shared_prefs

    HWVIE:/data/data/com.component.fx.plugin_toutiao $ cd databases/

    HWVIE:/data/data/com.component.fx.plugin_toutiao/databases $ ls

    TouTiao TouTiao-journal

    HWVIE:/data/data/com.component.fx.plugin_toutiao/databases $ dd if=TouTiao of=/sdcard/aaaaaaa

    40+0 records in

    40+0 records out

    20480 bytes transferred in 0.006 secs (3413333 bytes/sec)

    HWVIE:/data/data/com.component.fx.plugin_toutiao/databases $

    开源

    展开全文
  • Android 导出Excel

    2021-06-06 16:03:25
    build.gradleimplementation '...import android.content.Context;import android.os.Environment;import android.widget.Toast...

    build.gradle

    implementation 'net.sourceforge.jexcelapi:jxl:2.6.12'

    ExcelUtil

    package com.example.weijian.bluetooth;

    import android.content.Context;

    import android.os.Environment;

    import android.widget.Toast;

    import java.io.File;

    import java.io.FileInputStream;

    import java.io.IOException;

    import java.io.InputStream;

    import java.util.ArrayList;

    import java.util.List;

    import jxl.Workbook;

    import jxl.WorkbookSettings;

    import jxl.format.Colour;

    import jxl.write.Label;

    import jxl.write.WritableCell;

    import jxl.write.WritableCellFormat;

    import jxl.write.WritableFont;

    import jxl.write.WritableSheet;

    import jxl.write.WritableWorkbook;

    import jxl.write.WriteException;

    public class ExcelUtil { public static WritableFont arial14font = null;

    public static WritableCellFormat arial14format = null;

    public static WritableFont arial10font = null;

    public static WritableCellFormat arial10format = null;

    public static WritableFont arial12font = null;

    public static WritableCellFormat arial12format = null;

    public final static String UTF8_ENCODING = "UTF-8";

    public final static String GBK_ENCODING = "GBK";

    /**

    * 单元格的格式设置 字体大小 颜色 对齐方式、背景颜色等...

    */

    public static void format() {

    try {

    arial14font = new WritableFont(WritableFont.ARIAL, 14, WritableFont.BOLD);

    arial14font.setColour(jxl.format.Colour.LIGHT_BLUE);

    arial14format = new WritableCellFormat(arial14font);

    arial14format.setAlignment(jxl.format.Alignment.CENTRE);

    arial14format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);

    arial14format.setBackground(jxl.format.Colour.VERY_LIGHT_YELLOW);

    arial10font = new WritableFont(WritableFont.ARIAL, 10, WritableFont.BOLD);

    arial10format = new WritableCellFormat(arial10font);

    arial10format.setAlignment(jxl.format.Alignment.CENTRE);

    arial10format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN);

    arial10format.setBackground(Colour.GRAY_25);

    arial12font = new WritableFont(WritableFont.ARIAL, 10);

    arial12format = new WritableCellFormat(arial12font);

    arial10format.setAlignment(jxl.format.Alignment.CENTRE);//对齐格式

    arial12format.setBorder(jxl.format.Border.ALL,jxl.format.BorderLineStyle.THIN); //设置边框

    } catch (WriteException e) {

    e.printStackTrace();

    }

    }

    /**

    * 初始化Excel

    * @param fileName

    * @param colName

    */

    public static void initExcel(String fileName, String[] colName) {

    format();

    WritableWorkbook workbook = null;

    try {

    File file = new File(fileName);

    if (!file.exists()) {

    file.createNewFile();

    }

    workbook = Workbook.createWorkbook(file);

    WritableSheet sheet = workbook.createSheet("成绩表", 0);

    //创建标题栏

    sheet.addCell((WritableCell) new Label(0, 0, fileName,arial14format));

    for (int col = 0; col < colName.length; col++) {

    sheet.addCell(new Label(col, 0, colName[col], arial10format));

    }

    sheet.setRowView(0,340); //设置行高

    workbook.write();

    } catch (Exception e) {

    e.printStackTrace();

    } finally {

    if (workbook != null) {

    try {

    workbook.close();

    } catch (Exception e) {

    e.printStackTrace();

    }

    }

    }

    }

    @SuppressWarnings("unchecked")

    public static void writeObjListToExcel(List objList,String fileName, Context c) {

    if (objList != null && objList.size() > 0) {

    WritableWorkbook writebook = null;

    InputStream in = null;

    try {

    WorkbookSettings setEncode = new WorkbookSettings();

    setEncode.setEncoding(UTF8_ENCODING);

    in = new FileInputStream(new File(fileName));

    Workbook workbook = Workbook.getWorkbook(in);

    writebook = Workbook.createWorkbook(new File(fileName),workbook);

    WritableSheet sheet = writebook.getSheet(0);

    for (int j = 0; j < objList.size(); j++) {

    ArrayList list = (ArrayList) objList.get(j);

    for (int i = 0; i < list.size(); i++) {

    sheet.addCell(new Label(i, j + 1, list.get(i),arial12format));

    if (list.get(i).length() <= 5){

    sheet.setColumnView(i,list.get(i).length()+8); //设置列宽

    }else {

    sheet.setColumnView(i,list.get(i).length()+5); //设置列宽

    }

    }

    sheet.setRowView(j+1,350); //设置行高

    }

    writebook.write();

    Toast.makeText(c, "Success", Toast.LENGTH_SHORT).show();

    } catch (Exception e) {

    e.printStackTrace();

    } finally {

    if (writebook != null) {

    try {

    writebook.close();

    } catch (Exception e) {

    e.printStackTrace();

    }

    }

    if (in != null) {

    try {

    in.close();

    } catch (IOException e) {

    e.printStackTrace();

    }

    }

    }

    }

    }

    public static String getSDPath() {

    File sdDir = null;

    boolean sdCardExist = Environment.getExternalStorageState().equals(android.os.Environment.MEDIA_MOUNTED);

    if (sdCardExist) {

    sdDir = Environment.getExternalStorageDirectory();

    }

    String dir = sdDir.toString();

    return dir;

    }

    public static void makeDir(File dir) {

    if (!dir.getParentFile().exists()) {

    makeDir(dir.getParentFile());

    }

    dir.mkdir();

    }

    }

    MainActivity.java

    /**

    * 导出excel

    */

    public void exportExcel() {

    String[] title = { "时间","压力"};

    File file = new File(ExcelUtil.getSDPath() + "/bluetooth");

    ExcelUtil.makeDir(file);

    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

    String time = sdf.format(new Date());//Calendar.getInstance().toString();

    String fileName = file.toString() + "/"+testId+"-"+time+".xls";

    ExcelUtil.initExcel(fileName, title);

    ExcelUtil.writeObjListToExcel(getRecordData(), fileName, this);

    }

    /**

    * 将数据集合 转化成ArrayList>

    * @return

    */

    private ArrayList> getRecordData() {

    ArrayList> recordList = new ArrayList<>();

    for (int i = 0; i

    ArrayList beanList = new ArrayList();

    beanList.add(timeTexts.get(i));

    beanList.add(values.get(i).getY()+"");

    recordList.add(beanList);

    }

    return recordList;

    }

    展开全文
  • Android导出SQLite数据库

    2021-06-03 07:09:31
    Android导出SQLite数据库我使用从here & here企图出口SQLite数据库(/data/data/com.example.worldcountriesbooks/databases/group.db)了Android设备的例子(三星Galaxy Note) ,安卓4.0.3但我不断收到...
  • try {File sd = Environment.getExternalStorageDirectory();File data = Environment.getDataDirectory();if (sd.canWrite()) {String currentDBPath = "//data//{package name}//databases//{database name}";...
  • toExport() {if (this.dataList == false) {this.$createDialog({type:"alert",content:"数据為空",confirmBtn:"確定",icon:"cubeic-alert"}).show();}else{var that = this;this.$createDialog({type:"confirm",...
  • Android Studio如何导出apk文件

    千次阅读 多人点赞 2021-05-30 11:21:47
    我们平时写Android,大多数情况是在模拟器上运行调试。但实际开发中,有许多大型项目,比如无人车的操控,需要将应用放到遥控器上调试成功才行。有时候,大家也想把做好的APP放到自己手机上试一下。这时候,我们就...
  • 可借用这个库 https://github.com/amitshekhariitbhu/Android-Debug-Database
  • Android将数据导出为excel文件的方法

    千次阅读 2020-12-25 17:36:00
    项目中需要将未上传的数据导出到excel,供用户可见。不同的模块传入数据类型不一样。所以用了List<ArrayList>将数据封装成二维string类型。效率还挺高 build.gradle中引入jxl库。 // ...
  • adb shellshell@PD1616:/ cddata/anrshell@PD1616:/data/anr ll/system/bin/sh: ll: not found127|shell@PD1616:/data/anr $ lsAndroid 导出traces.txt 遇到的坑,我一直以为traces.txt 导出需要root...
  • android studio开发的app测试好之后需要签名发布发行版apk,如下将演示如何创建签名、如何导出apk。 步骤如下: 图一: 图二: 图三: 图四: 图5: 图6: 图7: 图8: 图...
  • Android Studio导出jar包

    2021-06-02 23:49:44
    一个Android Studio项目,编译成功之后就会在项目的app/build/intermediates/classes/debug目录下生成代码编译过后的class文件,因此只需通过打包命令将这些class文件打包成Jar包就好了,具体的途径看下边:在...
  • Unity与安卓aar 包交互本文提供全流程,中文翻译。Chinar 坚持将简单的生活方式,带给世人!(拥有更好的阅读体验 —— 高分辨率用户请根据需求调整网页缩放比例)Chinar —— 心分享、心创新!助力快速理两者 aar 包...
  • Firstly, Add this android:debuggable="false" in the application tag of the AndroidManifest.xml.You don't need to harcode android:debuggable="false" in your application tag. Infact for me studio compla...
  • 其实很简单,首先你要建个项目(废话)找到build.gradle文件(不是整个项目的那个),见下图Project视图下或者Android视图下打开它,进行一些修改apply plugin: 'com.android.application'android {compileSdkVersion 25...
  • Unity2020+ 导出安卓项目失败

    千次阅读 2021-11-16 20:54:52
    Unity2020+ 使用External Dependency Manager导出包错误
  • android手机导出日志adb logcat

    千次阅读 2021-10-29 14:26:05
    1、使用命令:adb logcat 配置环境变量: 这样就可以输除android手机上的日志信息了。
  • 到了研发后期,准备上线unity项目之后就要打包项目到手机上面,下面简单介绍下导出unity安卓android studio工程的处理1、打开unity工程,并且选中Build Setting2、并且按照箭头指向即可导出android studio工程,注意...
  • AndroidStudio 导出aar包(debug,release两种包),jar包并引用(未引用第三方jar包,aar包),修改导出的aar包 1.点击File ->New->New Module 2.进入Create New Module界面,点击Android Library,...
  • Android导出应用数据库

    2021-06-09 15:54:32
    Android开发的时候有时候会必须要导出自己APP的数据库,但是对于常用的Android手机很多都没有root权限,网站上流传的一些教程也是针对有root权限的,对于没有root权限的手机,大多是要开发者自己继续root,其实很多...
  • 一:在android Studio导出aar插件到unity 说明一下aar与jar插件的区别:jar是只包含配置文件和class文件,而aar插件是包括资源的,两者都能用压缩软件打开。 首先打开as建立新的工程(一直下一步下一步就行了) ...
  • 这款可以导出Android各种资源的Sketch插件的名字就是Android Res Export。有了这个安卓设计神器,可以轻轻松松导出各种PNG 资源、应用启动图标、点九(Nine-patch)图片、形状 XML 、色彩资源 XML 和矢量(Vector ...
  • 1.SDK location not found. 翻译的意思是:未找到SDK位置。使用local.properties文件...sdk.dir=D\:\\Software\\Android\\Sdk是我的Android sdk的安装目录 配置好后gradle重新Reload就可以 2.error: unknown ele
  • Android微信数据导出

    2021-06-06 17:38:49
    在Nexus 5(Android 4.4)+WeChat 5.4,和Nexus 5(Android 5.0)+Wechat 6.0上测试可用。获取加密的sqlite3数据库EnMicroMsg.db如果已经root过,可以下载/data/data/com.tencent.mm/MicroMsg/*/EnMicroMsg.db。若没有...
  • import android.util.Log; import java.io.File; import java.io.RandomAccessFile; public class DownloadUtils { /** * 将字符串写入到.txt文件中 */ public static void writeTxtToFile(String strcontent...
  • Mac android 导出anr文件

    2021-08-19 14:34:51
    1 root root 3797691 2021-08-19 14:24:27.211624085 +0800 dumptrace_CjsMof 文件夹如果有 traces.txt 就导出该文件查看 如果没有则导出 anr_2021-08-16-09-57-57-658 文件查看 (由于厂商对各个手机处理不一样...
  • 市面上有很多的在线Android安全扫描工具,比如梆梆的安全检测平台、360显危镜、爱加密安全检测平台等等,自动化工具出来的结果大多数情况下都是非准确的,都需要人工进行复核。这一章我们来学习Activity导出风险,...
  • 环境及工具准备 jdk安装配置 安装android-studio或idea(推荐直接使用idea,android-studio其实也是基于idea开发的...友情提示:创建一个Android文件夹,把再把安卓开发要用的工具及环境都再新建一个文件夹,比如这样

空空如也

空空如也

1 2 3 4 5 ... 20
收藏数 68,354
精华内容 27,341
关键字:

安卓导出