toExport() {
if (this.dataList == false) {
this.$createDialog({
type: "alert",
content: "数据為空",
confirmBtn: "確定",
icon: "cubeic-alert"
}).show();
} else {
var that = this;
this.$createDialog({
type: "confirm",
icon: "cubeic-alert",
content: "確定導出嗎?",
confirmBtn: {
text: "確定",
active: true,
disabled: false,
href: "javascript:;"
},
cancelBtn: {
text: "取消",
active: false,
disabled: false,
href: "javascript:;"
},
onConfirm: () => {
var data = [];
this.dataList.forEach(x => {
var datas = x.counter + "," + x.barcode + "," + x.qty + "\n";
//var datas = x.counter + "," + x.barcode + "," + x.qty;
data.push(datas);
});
//合并数组为字符串
var temp_string = data.join("");
//alert(temp_string)
//alert(window.requestFileSystem) window.requestFileSystem(
LocalFileSystem.PERSISTENT,
,
function(fs) {
//alert("open: " + fs.name);
fs.root.getFile(
"stocking.txt",
{ create: true, exclusive: false },
function(fileEntry) {
//alert(fileEntry);
//alert("is file?" + fileEntry.isFile.toString());
//文件内容
//alert (typeof temp_string)
// alert("插入的内容是"+temp_string)
var dataObj = new Blob([temp_string], {
type: "text/plain"
});
// var dataObj2 = new Blob(["temp_string"], {
// type: "text/plain"
// });
//写入文件
that.writeFile(fileEntry, dataObj);
//that.writeFile(fileEntry, dataObj2);
},
that.onErrorCreateFile
);
},
that.onErrorLoadFs
);
}
}).show();
}
//持久化数据保存
},
writeFile(fileEntry, dataObj) {
var that=this;
//创建一个写入对象
fileEntry.createWriter(function(fileWriter) {
//文件写入成功
fileWriter.onwriteend = function() {
that.contents="數據保存成功";
that.showPopup();
}; //文件写入失败
fileWriter.onerror = function(e) {
that.contents="數據保存失敗";
that.showPopup();
}; //写入文件
fileWriter.write(dataObj);
});
},

安卓端数据导出成txt文件的更多相关文章

  1. dataview将excel表格的数据导出成txt文件

    有时候需要处理大量的数据,且这些数据又存在于excel表格内,在平时的时候,我是非常喜欢这样的数据的,因为只要是excel表格内的数据,处理起来的方法就很方便.也可能我平时遇见的数据总是以一种杂乱无章 ...

  2. php 读取网页源码 , 导出成txt文件, 读取xls,读取文件夹下的所有文件的文件名

    <?php // 读取网页源码$curl = curl_init();curl_setopt($curl, CURLOPT_URL, $url);curl_setopt($curl, CURLO ...

  3. Pl/sql 如何将oracle的表数据导出成excel文件?

    oracle将表数据导出成excel文件的方法 1)在SQL窗体上,查询需要导出的数据 --查询数据条件-- ; 结果视图 2)在查询结果的空白处,右键选择Copy to Excel 3) 查看导出e ...

  4. 把mysql的数据导出成txt

    把mysql的数据导出成txt select a from b into outfile '/sqlfile/a.txt'; my.ini里需要设置secure_file_priv = d:/sqlf ...

  5. mysql中数据导出成excel文件语句

    代码如下 复制代码 mysql>select * from xi_table into outfile ’d:test.xls’; 导出为txt文件:  代码如下 复制代码 select * f ...

  6. es实战之数据导出成csv文件

    从es将数据导出分两步: 查询大量数据 将数据生成文件并下载 本篇主要是将第二步,第一步在<es实战之查询大量数据>中已讲述. csv vs excel excel2003不能超过6553 ...

  7. 数据库数据导出成XML文件

    在数据库中,怎样把库中的数据导出XML文件, sql语句如下: SELECT *  FROM 表名 FOR XML AUTO, ELEMENTS

  8. vue.js纯前端处理如何将后台返回来的csv数据导出成csv文件

    需要实现一个下载csv文件的功能,但后台没有对这个下载文件进行处理,而是将csv数据传给前台而已,需要前台做一下处理. 这是按钮的代码: <a> <el-button size=&q ...

  9. plsql 把数据导出成为 .sql文件,记住了

    今天上午,同事 提醒我.可以直接把数据导出成 .sql 文件,类似于 反编译.见下图

随机推荐

  1. sshpass: 用于非交互的ssh 密码验证

    ssh登陆不能在命令行中指定密码,也不能以shell中随处可见的,sshpass 的出现,解决了这一问题.它允许你用 -p 参数指定明文密码,然后直接登录远程服务器. 它支持密码从命令行,文件,环境变 ...

  2. (转)mysql百万级以上查询优化

    1.对查询进行优化,应尽量避免全表扫描,首先应考虑在 where 及 order by 涉及的列上建立索引. 2.应尽量避免在 where 子句中对字段进行 null 值判断,否则将导致引擎放弃使用索 ...

  3. StrokesPlus 谷歌搜索结果转https

    StrokesPlus 谷歌搜索结果转https 亲测ie11可用 --清空剪切板 acSetClipboardText('') acSendKeys("^l") --选中地址栏 ...

  4. javascript基础学习系列-DOM盒子模型常用属性

    最近在学习DOM盒子模型,各种属性看着眼花缭乱,下面根据三个系列来分别介绍一下: client系列 clientWidth :width+(padding-left)+(padding-right)— ...

  5. Linux环境变量与文件查找

    作业: 找出/etc目录下所有以.list结尾的文件 代码:locate /etc/\*.list sudo find /etc/ -name \*.list

  6. ThinkPHP框架 表单传值自动验证!!

    如果有多个字段都包含错误,默认只显示一个错误.如果想显示全部错误,可以设置属 性: //批量验证 d protected $patchValidate = true; 如果是直接 POST 过来的,直 ...

  7. PHP 代 码 操 作 文 件

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  8. C#5种方式生成缩略图

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  9. WordPlayer

    using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.D ...

  10. hdu2243 考研路茫茫——单词情结【AC自动机】【矩阵快速幂】

    考研路茫茫——单词情结 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...