ExcelUtils.js 24 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547
  1. MWF.xApplication.Template = MWF.xApplication.Template || {};
  2. MWF.xApplication.Template.utils = MWF.xApplication.Template.utils || {};
  3. MWF.xApplication.Template.utils.ExcelUtils = new Class({
  4. Implements: [Options, Events],
  5. options:{
  6. 'isTemplate': false,
  7. 'headText': '',
  8. 'headStyle': {
  9. font: { name: '宋体', family: 4, size: 20, bold: true },
  10. alignment: { vertical: 'middle', horizontal: 'center', wrapText: true }
  11. },
  12. 'columnTitleStyle': {
  13. font: { name: '宋体', family: 4, size: 12, bold: true },
  14. alignment: { vertical: 'middle', horizontal: 'center', wrapText: true }
  15. },
  16. 'columnContentStyle': {
  17. font: { name: '宋体', family: 4, size: 12, bold: false },
  18. alignment: { vertical: 'middle', horizontal: 'center', wrapText: true }
  19. }
  20. },
  21. initialize: function( options ){
  22. if(options)this.setOptions(options);
  23. this.sheet2JsonOptions = {};
  24. this.pollyfill();
  25. },
  26. pollyfill: function(){
  27. if (!FileReader.prototype.readAsBinaryString) {
  28. FileReader.prototype.readAsBinaryString = function (fileData) {
  29. var binary = "";
  30. var pt = this;
  31. var reader = new FileReader();
  32. reader.onload = function (e) {
  33. var bytes = new Uint8Array(reader.result);
  34. var length = bytes.byteLength;
  35. for (var i = 0; i < length; i++) {
  36. binary += String.fromCharCode(bytes[i]);
  37. }
  38. //pt.result - readonly so assign binary
  39. pt.content = binary;
  40. pt.onload();
  41. };
  42. reader.readAsArrayBuffer(fileData);
  43. }
  44. }
  45. },
  46. _openDownloadDialog: function(url, saveName, callback){
  47. /**
  48. * 通用的打开下载对话框方法,没有测试过具体兼容性
  49. * @param url 下载地址,也可以是一个blob对象,必选
  50. * @param saveName 保存文件名,可选
  51. */
  52. if( Browser.name !== 'ie' ){
  53. if(typeof url == 'object' && url instanceof Blob){
  54. url = URL.createObjectURL(url); // 创建blob地址
  55. }
  56. var aLink = document.createElement('a');
  57. aLink.href = url;
  58. aLink.download = saveName || ''; // HTML5新增的属性,指定保存文件名,可以不要后缀,注意,file:///模式下不会生效
  59. var event;
  60. if(window.MouseEvent && typeOf( window.MouseEvent ) == "function" ) event = new MouseEvent('click');
  61. else
  62. {
  63. event = document.createEvent('MouseEvents');
  64. event.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  65. }
  66. aLink.dispatchEvent(event);
  67. if(callback)callback();
  68. }else{
  69. window.navigator.msSaveBlob( url, saveName);
  70. if(callback)callback();
  71. }
  72. },
  73. index2ColName : function( index ){
  74. if (index < 0) {
  75. return null;
  76. }
  77. var num = 65;// A的Unicode码
  78. var colName = "";
  79. do {
  80. if (colName.length > 0)index--;
  81. var remainder = index % 26;
  82. colName = String.fromCharCode(remainder + num) + colName;
  83. index = (index - remainder) / 26;
  84. } while (index > 0);
  85. return colName;
  86. },
  87. upload : function ( dateColIndexArray, callback ) {
  88. var dateColArray = [];
  89. dateColIndexArray.each( function (idx) {
  90. dateColArray.push( this.index2ColName( idx ));
  91. }.bind(this))
  92. var uploadFileAreaNode = new Element("div");
  93. var html = "<input name=\"file\" type=\"file\" accept=\"csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel\" />";
  94. uploadFileAreaNode.set("html", html);
  95. var fileUploadNode = uploadFileAreaNode.getFirst();
  96. fileUploadNode.addEvent("change", function () {
  97. var files = fileNode.files;
  98. if (files.length) {
  99. var file = files.item(0);
  100. // if( file.name.indexOf(" ") > -1 ){
  101. // this.form.notice( MWF.xApplication.process.Xform.LP.uploadedFilesCannotHaveSpaces, "error");
  102. // return false;
  103. // }
  104. //第三个参数是日期的列
  105. this.importFromExcel( file, function(json){
  106. //json为导入的结果
  107. if(callback)callback(json);
  108. uploadFileAreaNode.destroy();
  109. }.bind(this), dateColArray ); //["E","F"]
  110. }
  111. }.bind(this));
  112. var fileNode = uploadFileAreaNode.getFirst();
  113. fileNode.click();
  114. },
  115. _loadExportResource : function( callback ){
  116. if( !window.ExcelJS ){
  117. var uri = "../o2_lib/exceljs/babel-polyfill-6.2.js";
  118. var uri2 = "../o2_lib/exceljs/exceljs.min.js";
  119. COMMON.AjaxModule.load(uri, function(){
  120. COMMON.AjaxModule.load(uri2, function(){
  121. callback();
  122. }.bind(this))
  123. }.bind(this))
  124. }else{
  125. callback();
  126. }
  127. },
  128. exportToExcel : function(array_arg, fileName_arg, colWidthArr_arg, dateIndexArray_arg, numberIndexArray_arg, callback){
  129. // var array = [["姓名","性别","学历","专业","出生日期","毕业日期"]];
  130. // array.push([ "张三","男","大学本科","计算机","2001-1-2","2019-9-2" ]);
  131. // array.push([ "李四","男","大学专科","数学","1998-1-2","2018-9-2" ]);
  132. // this.exportToExcel(array, "导出数据"+(new Date).format("db"));
  133. if( !MWF.xApplication.Template.LP ){
  134. MWF.xDesktop.requireApp("Template", "lp." + MWF.language, null, false);
  135. }
  136. this._loadExportResource(function (){
  137. var workbook = new ExcelJS.Workbook();
  138. var sheet = workbook.addWorksheet('Sheet1');
  139. //sheet.properties.defaultRowHeight = 25;
  140. var arg = {
  141. offsetColumnIndex: 0,
  142. offsetRowIndex: 0,
  143. sheet: sheet,
  144. fileName: fileName_arg,
  145. array: array_arg,
  146. colWidthArr: colWidthArr_arg,
  147. dateIndexArray: dateIndexArray_arg,
  148. numberIndexArray: numberIndexArray_arg,
  149. excelUtilsObject: this
  150. };
  151. this.fireEvent('beforeAppendData', [arg]);
  152. var offsetColumnIndex = arg.offsetColumnIndex;
  153. var offsetRowIndex = arg.offsetRowIndex;
  154. var array = arg.array;
  155. var colWidthArr = arg.colWidthArr;
  156. var dateIndexArray = arg.dateIndexArray;
  157. var numberIndexArray = arg.numberIndexArray;
  158. var titleArray = array[0];
  159. this.appendDataToSheet(sheet, array, colWidthArr, dateIndexArray, numberIndexArray, offsetColumnIndex, offsetRowIndex);
  160. var hasValidation = false;
  161. var ps = titleArray.map(function( title ){
  162. if( o2.typeOf(title) === 'object' && title.options ){
  163. hasValidation = true;
  164. return title.options;
  165. }
  166. return null;
  167. });
  168. if(hasValidation){
  169. Promise.all(ps).then(function(args){
  170. for( var i=0; i<args.length; i++ ){
  171. if(args[i])titleArray[i].optionsValue = args[i];
  172. }
  173. this.setDataValidation(workbook, sheet, titleArray, offsetColumnIndex, offsetRowIndex);
  174. this.fireEvent('beforeDownload', [arg]);
  175. this.downloadExcel(workbook, arg.fileName, callback);
  176. }.bind(this));
  177. }else{
  178. this.fireEvent('beforeDownload', [arg]);
  179. this.downloadExcel(workbook, arg.fileName, callback);
  180. }
  181. }.bind(this));
  182. },
  183. downloadExcel: function(workbook, fileName, callback){
  184. workbook.xlsx.writeBuffer().then(function(buffer){
  185. var blob = new Blob([buffer]);
  186. this._openDownloadDialog(blob, fileName + ".xlsx", callback);
  187. }.bind(this));
  188. },
  189. appendDataToSheet: function (sheet, array, colWidthArr, dateIndexArray, numberIndexArray, offsetColumnIndex, offsetRowIndex){
  190. // var titleRow = sheet.getRow(1);
  191. var titleArray = array.shift();
  192. titleArray.each( function( title, i ){
  193. sheet.getColumn(i+1+offsetColumnIndex).width = colWidthArr[i] ? (colWidthArr[i] / 10) : 20;
  194. });
  195. debugger;
  196. var startCol = this.index2ColName(offsetColumnIndex), endCol = this.index2ColName(titleArray.length-1+offsetColumnIndex);
  197. if( this.options.headText ){
  198. var headRow = sheet.getRow(1+offsetRowIndex);
  199. var headCell = headRow.getCell(1+offsetColumnIndex);
  200. headCell.value = this.options.headText;
  201. Object.each(this.options.headStyle || {}, function (value, key){
  202. headCell[key] = value;
  203. });
  204. sheet.mergeCells( startCol+(offsetRowIndex+1)+":"+ endCol+(offsetRowIndex+1));
  205. offsetRowIndex++;
  206. }
  207. //处理表头分类
  208. var titleDataParsed = [];
  209. var maxTitleLevel = 1;
  210. titleArray.each(function (title, i){
  211. var text = o2.typeOf(title) === 'object' ? title.text : title;
  212. var texts = ( text || " " ).split('\\');
  213. maxTitleLevel = Math.max( maxTitleLevel, texts.length );
  214. titleDataParsed.push( texts );
  215. });
  216. var setTitleCellStyle = function (cell){
  217. //cell.font = { name: '宋体', family: 4, size: 12, bold: true };
  218. // cell.fill = { type: 'pattern', pattern:'solid', fgColor:{argb:'FFFFFF'} };
  219. //cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: true };
  220. Object.each(this.options.columnTitleStyle || {}, function (value, key){
  221. cell[key] = value;
  222. });
  223. }.bind(this);
  224. var setDataCellStyle = function(cell, index){
  225. var isDate = (dateIndexArray || []).contains( index );
  226. var isNumber = ( numberIndexArray||[] ).contains( index );
  227. var style = this.options.columnContentStyle || {};
  228. if( isDate ){
  229. cell.numFmt = 'yyyy-mm-dd HH:MM:SS';
  230. }else if( isNumber ){
  231. if( style.alignment && style.alignment.wrapText ){
  232. style.alignment.wrapText = false;
  233. }
  234. }else{
  235. cell.numFmt = '@';
  236. }
  237. Object.each(style || {}, function (value, key){
  238. cell[key] = value;
  239. });
  240. }.bind(this);
  241. for( var level=0 ;level<maxTitleLevel; level++ ){
  242. var titleRow = sheet.getRow(level+1+offsetRowIndex);
  243. var lastValue = '';
  244. var lastCell = null;
  245. var lastIndex = -1;
  246. var lastTitles = null;
  247. var lastAvailableIndex = -1;
  248. var startColName, starRowIndex, endColName, endRowIndex;
  249. titleDataParsed.each( function(titles, i){
  250. if( !titles[level] )return;
  251. lastAvailableIndex = i;
  252. if( lastValue !== titles[level] ){
  253. var cell = titleRow.getCell(i+1+offsetColumnIndex);
  254. cell.value = titles[level];
  255. setTitleCellStyle(cell);
  256. if(lastTitles && lastCell ){
  257. //sheet.mergeCells('A2:A3');
  258. startColName = this.index2ColName(lastIndex+offsetColumnIndex);
  259. starRowIndex = level+1+offsetRowIndex;
  260. endColName = this.index2ColName(i-1+offsetColumnIndex);
  261. endRowIndex = (lastTitles[level+1] ? level+1 : maxTitleLevel)+offsetRowIndex;
  262. if( (startColName !== endColName || starRowIndex !== endRowIndex) && (i===0 || titleDataParsed[i-1][leve]) ){
  263. sheet.mergeCells(startColName+starRowIndex+':'+endColName+endRowIndex);
  264. }
  265. }
  266. lastValue = titles[level];
  267. lastCell = cell;
  268. lastIndex = i;
  269. lastTitles = titles;
  270. }
  271. }.bind(this));
  272. debugger;
  273. if(lastTitles && lastCell && lastTitles[level] ){
  274. //sheet.mergeCells('A2:A3');
  275. startColName = this.index2ColName(lastIndex+offsetColumnIndex);
  276. starRowIndex = level+1+offsetRowIndex;
  277. endColName = this.index2ColName(lastAvailableIndex+offsetColumnIndex);
  278. endRowIndex = (lastTitles[level+1] ? level+1 : maxTitleLevel)+offsetRowIndex;
  279. if( startColName !== endColName || starRowIndex !== endRowIndex ){
  280. sheet.mergeCells(startColName+starRowIndex+':'+endColName+endRowIndex);
  281. }
  282. }
  283. }
  284. // titleArray.each( function( title, i ){
  285. // sheet.getColumn(i+1).width = colWidthArr[i] ? (colWidthArr[i] / 10) : 20;
  286. // var cell = titleRow.getCell(i+1);
  287. // cell.value = o2.typeOf(title) === 'object' ? title.text : title;
  288. // cell.font = { name: '宋体', family: 4, size: 12, bold: true };
  289. // // cell.fill = { type: 'pattern', pattern:'solid', fgColor:{argb:'FFFFFF'} };
  290. // cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: true };
  291. // });
  292. if( array.length ){
  293. array.each(function( contentArray, i ){
  294. var contentRow = sheet.getRow(i+1+maxTitleLevel+offsetRowIndex);
  295. contentArray.each(function( content, j ){
  296. var cell = contentRow.getCell(j+1+offsetColumnIndex);
  297. cell.value = content;
  298. setDataCellStyle( cell, j );
  299. // cell.font = { name: '宋体', family: 4, size: 12, bold: false };
  300. // cell.alignment = { vertical: 'middle', horizontal: 'center', wrapText: !isNumber };
  301. }.bind(this));
  302. }.bind(this));
  303. }else if( this.options.isTemplate ){
  304. for (var rowIndex = 0; rowIndex < 3000; rowIndex++) {
  305. var row = sheet.getRow(rowIndex+1+maxTitleLevel+offsetRowIndex );
  306. titleDataParsed.each(function(titles, colIndex){
  307. var cell = row.getCell(colIndex+1+offsetColumnIndex);
  308. setDataCellStyle( cell, colIndex );
  309. }.bind(this));
  310. }
  311. }
  312. },
  313. setDataValidation: function (workbook, dataSheet, titleArray, offsetColumnIndex, offsetRowIndex){
  314. var validationSheet = workbook.addWorksheet('Validation');
  315. validationSheet.state = 'hidden'; //hidden 隐藏 veryHidden 从“隐藏/取消隐藏”对话框中隐藏工作表
  316. var colIndex = 0;
  317. titleArray.each(function(title, i){
  318. var optionsValue = o2.typeOf(title) === 'object' && title.optionsValue;
  319. if( !optionsValue )return;
  320. colIndex++;
  321. var optionsArray = o2.typeOf(optionsValue) === "array" ? optionsValue : [optionsValue];
  322. validationSheet.getColumn(colIndex).values = optionsArray;
  323. var colName = this.index2ColName(colIndex-1);
  324. var dataValidation = {
  325. type: 'list',
  326. allowBlank: true,
  327. showErrorMessage: true,
  328. showInputMessage: false,
  329. formulae: ['=Validation!$'+colName+'$1:$'+colName+'$'+optionsArray.length], // 这里引用Validation Sheet的内容 '=Validation!A1:A3'
  330. //formulae: ['"'+optionsArray.join(",")+'"'],
  331. promptTitle: MWF.xApplication.Template.LP.excelUtils.promptTitle,
  332. prompt: MWF.xApplication.Template.LP.excelUtils.prompt,
  333. errorTitle: MWF.xApplication.Template.LP.excelUtils.errorTitle,
  334. error: MWF.xApplication.Template.LP.excelUtils.error
  335. };
  336. var dataColName = this.index2ColName(i+offsetColumnIndex);
  337. for (var rowIndex = 2+offsetRowIndex; rowIndex <= 3000+offsetRowIndex; rowIndex++) {
  338. const cell = dataSheet.getCell(dataColName+rowIndex);
  339. cell.dataValidation = dataValidation;
  340. }
  341. }.bind(this));
  342. },
  343. // exportToExcel2: function(array, fileName, colWidthArr, dateIndexArray, numberIndexArray, callback){
  344. // // var array = [["姓名","性别","学历","专业","出生日期","毕业日期"]];
  345. // // array.push([ "张三","男","大学本科","计算机","2001-1-2","2019-9-2" ]);
  346. // // array.push([ "李四","男","大学专科","数学","1998-1-2","2018-9-2" ]);
  347. // // this.exportToExcel(array, "导出数据"+(new Date).format("db"));
  348. // this._loadExportResource( function(){
  349. // var data = window.xlsxUtils.format2Sheet(array, 0, 0, null);//偏移3行按keyMap顺序转换
  350. // var wb = window.xlsxUtils.format2WB(data, "sheet1", undefined);
  351. // var wopts = { bookType: 'xlsx', bookSST: false, type: 'binary' };
  352. // debugger;
  353. // var dataInfo = wb.Sheets[wb.SheetNames[0]];
  354. //
  355. // var widthArray = [];
  356. // array[0].each( function( v, i ){ //设置标题行样式
  357. //
  358. // if( !colWidthArr )widthArray.push( {wpx: 100} );
  359. //
  360. // // var at = String.fromCharCode(97 + i).toUpperCase();
  361. // var at = this.index2ColName(i);
  362. // var di = dataInfo[at+"1"];
  363. // // di.v = v;
  364. // // di.t = "s";
  365. // di.s = { //设置副标题样式
  366. // font: {
  367. // //name: '宋体',
  368. // sz: 12,
  369. // color: {rgb: "#FFFF0000"},
  370. // bold: true,
  371. // italic: false,
  372. // underline: false
  373. // },
  374. // alignment: {
  375. // horizontal: "center" ,
  376. // vertical: "center"
  377. // }
  378. // };
  379. // }.bind(this));
  380. //
  381. // if( dateIndexArray && dateIndexArray.length ){
  382. // dateIndexArray.each( function( value, index ){
  383. // dateIndexArray[ index ] = this.index2ColName(value);
  384. // }.bind(this))
  385. // }
  386. //
  387. // if( numberIndexArray && numberIndexArray.length ){
  388. // numberIndexArray.each( function( value, index ){
  389. // numberIndexArray[ index ] = this.index2ColName(value);
  390. // }.bind(this))
  391. // }
  392. //
  393. // var typeFlag = ( dateIndexArray && dateIndexArray.length ) || ( numberIndexArray && numberIndexArray.length );
  394. //
  395. // for( var key in dataInfo ){
  396. // //设置所有样式,wrapText=true 后 /n会被换行
  397. // if( key.substr(0, 1) !== "!" ){
  398. // var di = dataInfo[key];
  399. // if( !di.s )di.s = {};
  400. // if( !di.s.alignment )di.s.alignment = {};
  401. // di.s.alignment.wrapText = true;
  402. //
  403. // if( typeFlag ){
  404. //
  405. // var colName = key.replace(/\d+/g,''); //清除数字
  406. // var rowNum = key.replace( colName, '');
  407. //
  408. // if( rowNum > 1 ){
  409. // if( dateIndexArray && dateIndexArray.length && dateIndexArray.contains( colName ) ){
  410. // //di.s.numFmt = "yyyy-mm-dd HH:MM:SS"; //日期列 两种方式都可以
  411. // di.z = 'yyyy-mm-dd HH:MM:SS'; //日期列
  412. // }
  413. // if( numberIndexArray && numberIndexArray.length && numberIndexArray.contains( colName ) ){
  414. // di.s.alignment.wrapText = false;
  415. // di.t = 'n'; //数字类型
  416. // }
  417. // }
  418. //
  419. // }
  420. // }
  421. //
  422. // }
  423. //
  424. // if( colWidthArr ){
  425. // colWidthArr.each( function (w) {
  426. // widthArray.push( {wpx: w} );
  427. // })
  428. // }
  429. // dataInfo['!cols'] = widthArray; //列宽度
  430. //
  431. // this._openDownloadDialog(window.xlsxUtils.format2Blob(wb), fileName +".xlsx", callback);
  432. // }.bind(this))
  433. // },
  434. _loadImportResource : function( callback ){
  435. if( !window.XLSX || !window.xlsxUtils ){
  436. var uri = "../x_component_Template/framework/xlsx/xlsx.full.js";
  437. var uri2 = "../x_component_Template/framework/xlsx/xlsxUtils.js";
  438. COMMON.AjaxModule.load(uri, function(){
  439. COMMON.AjaxModule.load(uri2, function(){
  440. callback();
  441. }.bind(this))
  442. }.bind(this))
  443. }else{
  444. callback();
  445. }
  446. },
  447. importFromExcel : function( file, callback, dateColArray ){
  448. debugger;
  449. var _self = this;
  450. this._loadImportResource( function(){
  451. var reader = new FileReader();
  452. var workbook, data;
  453. reader.onload = function (e) {
  454. //var data = data.content;
  455. if (!e) {
  456. data = reader.content;
  457. }else {
  458. data = e.target.result;
  459. }
  460. workbook = window.XLSX.read(data, {
  461. type:'binary',
  462. cellText:false,
  463. cellDates:true,
  464. dateNF:'yyyy-mm-dd HH:mm:ss'
  465. });
  466. //wb.SheetNames[0]是获取Sheets中第一个Sheet的名字
  467. //wb.Sheets[Sheet名]获取第一个Sheet的数据
  468. var sheet = workbook.SheetNames[0];
  469. if (workbook.Sheets.hasOwnProperty(sheet)) {
  470. var worksheet = workbook.Sheets[sheet];
  471. if( dateColArray && typeOf(dateColArray) == "array" && dateColArray.length ){
  472. var rowCount;
  473. if( worksheet['!range'] ){
  474. rowCount = worksheet['!range'].e.r;
  475. }else{
  476. var ref = worksheet['!ref'];
  477. var arr = ref.split(":");
  478. if(arr.length === 2){
  479. rowCount = parseInt( arr[1].replace(/[^0-9]/ig,"") );
  480. }
  481. }
  482. if( rowCount ){
  483. for( var i=0; i<dateColArray.length; i++ ){
  484. for( var j=1; j<=rowCount; j++ ){
  485. var cell = worksheet[ dateColArray[i]+j ];
  486. if( cell ){
  487. delete cell.w; // remove old formatted text
  488. cell.z = 'yyyy-mm-dd HH:mm:ss'; // set cell format
  489. window.XLSX.utils.format_cell(cell); // this refreshes the formatted text.
  490. }
  491. }
  492. }
  493. }
  494. }
  495. var opt = _self.sheet2JsonOptions;
  496. opt.raw = false;
  497. opt.dateNF = 'yyyy-mm-dd HH:mm:ss'; //'yyyy-mm-dd';
  498. var json = window.XLSX.utils.sheet_to_json( worksheet, opt );
  499. if(callback)callback(json);
  500. // break; // 如果只取第一张表,就取消注释这行
  501. }
  502. };
  503. reader.readAsBinaryString(file);
  504. })
  505. }
  506. });