• 读取excel数据到数据库里


    用的是jxlJar

    /**

     * 读取excel数据到数据库里

     */

    private void readExcelToDB() {

        new Thread(new Runnable() {

            @Override

            public void run() {

                try {

                    String filePath = "/sdcard/";

                    String fileName = "307322.xlsx";

                    File file = new File(filePath, fileName);

                    FileInputStream is = new FileInputStream(file);

                    Workbook book = Workbook.getWorkbook(is);

                    // 获取表页数

                    final int bookPage = book.getNumberOfSheets();

                    Log.e("bookPage", "bookPage = " + bookPage);

                    // 获得第一个工作表对象

                    Sheet sheet = book.getSheet(0);

                    int Rows = sheet.getRows();

                    for (int i = 1; i < Rows; ++i) {

                        String assetNumber = (sheet.getCell(0, i)).getContents();

                        String assetName = (sheet.getCell(3, i)).getContents();

                        String sTmp8 = sheet.getCell(8, i).getContents();

                        String sTmp9 = sheet.getCell(9, i).getContents();

                    }

                    book.close();

                    runOnUiThread(new Runnable() {

                        @Override

                        public void run() {

                            Toast.makeText(ActivityMain.this, "导入成功", Toast.LENGTH_SHORT).show();

                        }

                    });

                } catch (Exception e) {

                    runOnUiThread(new Runnable() {

                        @Override

                        public void run() {

                            Toast.makeText(ActivityMain.this, "导入失败", Toast.LENGTH_SHORT).show();

                        }

                    });

                }

            }

        }).start();

    }

  • 相关阅读:
    OpenERP实施记录(12):付款处理
    OpenERP实施记录(10):采购补货
    OpenERP实施记录(9):销售一批电脑
    从一个action地址获取信息
    在线杀毒 (最大文件大小64MB)
    WIN7启动WIFI
    Lazy Load, 延迟加载图片的 jQuery 插件【备忘】
    Android 汉字转拼音之JNI篇
    Android Studio 解决方法No JVM installation found. Please install a 64-bit JDK.
    Unity3D移植到自己的Android程序
  • 原文地址:https://www.cnblogs.com/CipherLab/p/11826616.html
Copyright © 2020-2023  润新知