第一: 在iframe框架中实现 加载中的效果
html部分(main.html)主页面
<body>
<div class="mask" id="mask" style="display:none;">
<div id="loading" class="loading">数据正在同步中...</div>
</div>
<div>
页面中的内容...
</div>
</body>
js部分(main.html)主页面
<script type="text/javascript">
function Block(){
document.getElementById("mask").style.display="block";
}
function None(){
document.getElementById("mask").style.display="none";
}
</script>
剩下的部分就是开始调用。主要的调用的方式就是,在需要加载的界面中调用main.html中
定义的俩个方法即可。例window.parent.Block();调用显示,window.parent.None();调用影藏
css部分(main.html)主页面
<style>
.loading{
width:160px;
height:56px;
position: absolute;
top:50%;
left:50%;
line-height:56px;
color:#fff;
padding-left:60px;
font-size:15px;
background: #000 url(../images/loader.gif) no-repeat 10px 50%;
opacity: 0.7;
z-index:9999;
-moz-border-radius:20px;
-webkit-border-radius:20px;
border-radius:20px;
filter:progid:DXImageTransform.Microsoft.Alpha(opacity=70);
}
.main { width:960px; height:800px; background-color:#FF9966; margin:0px auto;}
.mask{ z-index:900; position:fixed!important; position:absolute; left:0px; top:0px; width:100%; height:100%; background:#000; filter: alpha(opacity=45); opacity: 0.45; -moz-opacity: 0.45; -khtml-opacity: 0.45; }
</style>
所需图片部分。
第二:使用jxl进行excel的数据,输入、输出
所需jar : jxl-2.6.3.jar
java代码部分:
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import com.hjsj.domain.FileCommodity;
import jxl.Cell;
import jxl.Sheet;
import jxl.Workbook;
import jxl.write.Label;
import jxl.write.WritableSheet;
import jxl.write.WritableWorkbook;
import jxl.write.WriteException;
public class InExcel {
/**
* 针对Book类进行导出的操作
* @param list
*/
public static void excleOut(List<FileCommodity> list) {
WritableWorkbook book = null;
try {
// 创建一个excle对象
book = Workbook.createWorkbook(new File("c:/SynchronizationFailure.xls"));
// 通过excle对象创建一个选项卡对象
WritableSheet sheet = book.createSheet("sheet1", 0);
// 创建一个单元格对象 列 行 值
// Label label = new Label(0, 2, "test");
for (int i = 0; i < list.size(); i++) {
FileCommodity book2 = list.get(i);
Label label1 = new Label(0, i, String.valueOf(book2.getId()));
Label label2 = new Label(1, i, book2.getSku());
Label label3 = new Label(2, i, book2.getSiteCode());
Label label4 = new Label(3, i, book2.getUnit());
Label label5 = new Label(4, i, book2.getPlaceOfOrigin());
Label label6 = new Label(5, i, book2.getSpecification());
Label label7 = new Label(6, i, book2.getQrCode());
Label label8 = new Label(7, i, book2.getPrice2());
Label label9 = new Label(8, i, book2.getPrice3());
Label label10 = new Label(9, i, book2.getPrice5());
Label label11= new Label(10, i, book2.getGrade());
Label label12 = new Label(11, i, book2.getPromoDateFrom());
Label label13 = new Label(12, i, book2.getPromoDateTo());
Label label14 = new Label(13, i, book2.getPromoTimeFrom());
Label label15 = new Label(13, i, book2.getPromoTimeTo());
Label label16 = new Label(13, i, book2.getVipDateFrom());
Label label17 = new Label(13, i, book2.getVipDateTo());
Label label18 = new Label(13, i, book2.getVipTimeFrom());
Label label19 = new Label(13, i, book2.getVipTimeTo());
// 将创建好的单元格对象放入选项卡中
sheet.addCell(label1);
sheet.addCell(label2);
sheet.addCell(label3);
sheet.addCell(label4);
sheet.addCell(label5);
sheet.addCell(label6);
sheet.addCell(label7);
sheet.addCell(label8);
sheet.addCell(label9);
sheet.addCell(label10);
sheet.addCell(label11);
sheet.addCell(label12);
sheet.addCell(label13);
sheet.addCell(label14);
sheet.addCell(label15);
sheet.addCell(label16);
sheet.addCell(label17);
sheet.addCell(label18);
sheet.addCell(label19);
}
// 写入目标路径
book.write();
} catch (Exception e) {
e.printStackTrace();
} finally {
try {
book.close();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
/**
* 针对Book类进行导入的操作
* @return
*/
public List<FileCommodity> excleIn() {
List<FileCommodity> list = new ArrayList<>();
Workbook workbook = null;
try {
// 获取Ecle对象
workbook = Workbook.getWorkbook(new File("c:/book.xls"));
// 获取选项卡对象 第0个选项卡
Sheet sheet = workbook.getSheet(0);
// 循环选项卡中的值
for (int i = 0; i < sheet.getRows(); i++) {
FileCommodity book = list.get(i);
// 获取单元格对象
Cell cell0 = sheet.getCell(0, i);
// 取得单元格的值,并设置到对象中
book.setId(Integer.valueOf(cell0.getContents()));
// 获取单元格对象,然后取得单元格的值,并设置到对象中
book.setSku(sheet.getCell(1, i).getContents());
book.setSiteCode(sheet.getCell(2, i).getContents());
book.setUnit(sheet.getCell(3, i).getContents());
book.setPlaceOfOrigin(sheet.getCell(4, i).getContents());
book.setSpecification(sheet.getCell(5, i).getContents());
book.setQrCode(sheet.getCell(6, i).getContents());
book.setPrice2(sheet.getCell(7, i).getContents());
book.setPrice3(sheet.getCell(8, i).getContents());
book.setPrice5(sheet.getCell(9, i).getContents());
book.setGrade(sheet.getCell(10, i).getContents());
book.setPromoDateFrom(sheet.getCell(11, i).getContents());
book.setPromoDateTo(sheet.getCell(12, i).getContents());
book.setPromoTimeFrom(sheet.getCell(13, i).getContents());
book.setPromoTimeTo(sheet.getCell(14, i).getContents());
book.setVipDateFrom(sheet.getCell(15, i).getContents());
book.setVipDateTo(sheet.getCell(16, i).getContents());
book.setVipTimeFrom(sheet.getCell(17, i).getContents());
book.setVipTimeTo(sheet.getCell(18, i).getContents());
list.add(book);
}
} catch (Exception e) {
e.printStackTrace();
} finally {
workbook.close();
}
return list;
}