财务比较2

master
chenzhi 5 years ago
parent 48e5e4d824
commit ea69ecb086

@ -2,10 +2,14 @@
namespace Admin\Controller; namespace Admin\Controller;
class FinanceCompareController extends ThinkController class FinanceCompareController extends ThinkController
{ {
public function add() public function add()
{ {
$this->display(); $this->display();
# code... # code...
} }
public function compareData()
{
$data = I('POST.');
//过滤数据
}
} }

@ -81,6 +81,7 @@
</block> </block>
<block name="script"> <block name="script">
<script type="text/javascript" src="__STATIC__/xlsx.core.min.js" charset="UTF-8"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script> <script type="text/javascript" src="__STATIC__/datetimepicker/js/bootstrap-datetimepicker.min.js"></script>
<script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script> <script type="text/javascript" src="__STATIC__/datetimepicker/js/locales/bootstrap-datetimepicker.zh-CN.js" charset="UTF-8"></script>
<script type="text/javascript"> <script type="text/javascript">
@ -93,6 +94,47 @@ Think.setValue("category", {$data.category|default = 0});
$(function(){ $(function(){
showTab(); showTab();
var wb;//读取完成的数据
var rABS = false; //是否将文件读取为二进制字符串
function fixdata(data) { //文件流转BinaryString
var o = "",
l = 0,
w = 10240;
for(; l < data.byteLength / w; ++l) o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w, l * w + w)));
o += String.fromCharCode.apply(null, new Uint8Array(data.slice(l * w)));
return o;
}
$("#fileinput").change(function(){
if(!this.files) {
return;
}
var f = this.files[0];
var reader = new FileReader();
if(rABS) {
reader.readAsArrayBuffer(f);
} else {
reader.readAsBinaryString(f);
}
reader.onload = function(e) {
var data = e.target.result;
if(rABS) {
wb = XLSX.read(btoa(fixdata(data)),{
type: 'base64'
});
} else {
wb = XLSX.read(data,{
type: 'binary'
});
}
console.log(wb.Sheets[wb.SheetNames[0]])
console.log(XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) )
// document.getElementById("demo").innerHTML= JSON.stringify( XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]) );
};
})
}); });

File diff suppressed because one or more lines are too long
Loading…
Cancel
Save