相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
- PHP中opcode緩存簡(jiǎn)單用法分析
- thinkPHP控制器變量在模板中的顯示方法示例
- PHP move_uploaded_file() 函數(shù)(將上傳的文件移動(dòng)到新位置)
- dirname(__FILE__)的含義和應(yīng)用說(shuō)明
- thinkPHP5框架實(shí)現(xiàn)分頁(yè)查詢功能的方法示例
- PHP中單雙號(hào)與變量
- PHP獲得當(dāng)日零點(diǎn)時(shí)間戳的方法分析
- Laravel ORM對(duì)Model::find方法進(jìn)行緩存示例詳解
- PHP讀寫文件高并發(fā)處理操作實(shí)例詳解
- 【CLI】利用Curl下載文件實(shí)時(shí)進(jìn)度條顯示的實(shí)現(xiàn)
基于yaf框架和uploadify插件,做的一個(gè)導(dǎo)入excel文件,查看并保存數(shù)據(jù)的功能
思路:
1.首先,頁(yè)面前端,上傳附件,提交給后臺(tái),并帶一個(gè)隨機(jī)性的參數(shù)(可以用時(shí)間戳);
2.后端接收附件,做一系列的邏輯處理,無(wú)誤后,將對(duì)應(yīng)的文件存儲(chǔ)在上傳的目錄下;
3.然后前端,上傳附件成功后,進(jìn)行請(qǐng)求后端,讀取數(shù)據(jù),后端接口對(duì)應(yīng)將附件數(shù)據(jù)讀取出來(lái),前端進(jìn)行顯示(ajax請(qǐng)求);
4.前端展示數(shù)據(jù),用戶對(duì)數(shù)據(jù)檢測(cè)無(wú)誤,點(diǎn)擊保存(ajax請(qǐng)求后端保存代碼的接口),當(dāng)然也可以有選擇性的選擇某些數(shù)據(jù)記錄進(jìn)行保存,樓主這里做的是全部保存(后端處理接口,自動(dòng)過(guò)濾重復(fù)數(shù)據(jù));
5.拿到對(duì)應(yīng)的所需有用數(shù)據(jù)即可, 對(duì)應(yīng)的excel表格,因?yàn)樾枰@取到人員排期數(shù)據(jù),所以樓主是通過(guò)判斷單元格的背景色來(lái)識(shí)別
代碼如下:(關(guān)鍵代碼)
前端 對(duì)應(yīng)html:
<!--導(dǎo)入數(shù)據(jù)操作層--> <div id="import" class="modal fade bs-modal-lg" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true"> <div class="modal-dialog modal-lg"> <div class="modal-content"> <div class="modal-header bg-primary"> <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button> <h4 class="modal-title">文件導(dǎo)入</h4> </div> <div class="modal-body"> <div style="text-align:right;padding:5px"> <a href="/public/uploadFile/人員資源動(dòng)態(tài)匹配表-模板.xlsx" onclick="javascript:;"> <img alt="人員資源動(dòng)態(tài)匹配表-模板" src="/public/images/excel.jpg" /> <span style="font-size:larger;font-weight:200;color:red">人員資源動(dòng)態(tài)匹配表-模板.xlsx</span> </a> </div> <hr/> <form id="ffImport" method="post"> <div title="Excel導(dǎo)入操作" style="padding: 5px" data-options="iconCls:'icon-key'"> <input class="easyui-validatebox" type="hidden" id="AttachGUID" name="AttachGUID" /> <input id="file_upload" name="file_upload" type="file" multiple="multiple"> <a href="javascript:;" class="btn btn-primary" id="btnUpload" onclick="javascript: $('#file_upload').uploadify('upload', '*')">上傳</a> <a href="javascript:;" class="btn btn-default" id="btnCancelUpload" onclick="javascript: $('#file_upload').uploadify('cancel', '*')">取消</a> <div id="fileQueue" class="fileQueue"></div> <br /> <hr style="width:98%" /> <div id="div_files"></div> <br /> </div> </form> <!--數(shù)據(jù)顯示表格--> <table id="gridImport" class="table table-striped table-bordered table-hover" cellpadding="0" cellspacing="0" border="0" class="display" width="100%"> <thead id="gridImport_head"> <tr> <th>項(xiàng)目名稱</th> <th>項(xiàng)目編號(hào)</th> <th>功 能</th> <th>人 員</th> <th>日 期</th> </tr> </thead> <tbody id="gridImport_body"></tbody> </table> </div> <div class="modal-footer"> <button type="button" class="btn btn-default" data-dismiss="modal" id="close_window">關(guān)閉</button> <button type="button" class="btn btn-primary" onclick="javascript:SaveImport();">保存</button> </div> </div> </div> </div>