Chinaunix首页 | 论坛 | 博客
  • 博客访问: 701099
  • 博文数量: 158
  • 博客积分: 6010
  • 博客等级: 准将
  • 技术积分: 1643
  • 用 户 组: 普通用户
  • 注册时间: 2007-10-11 14:37
个人简介

人法地,地法天,天法道,道法自然

文章分类

全部博文(158)

文章存档

2022年(1)

2020年(3)

2016年(1)

2014年(7)

2013年(4)

2010年(5)

2009年(86)

2008年(25)

2007年(26)

我的朋友

分类: Java

2008-06-25 15:52:52

关于数据修改后用颜色标记的方法设想
在测试中,工程部要求被修改过的数据用颜色标识,此问题不太好解决,因为就现有的系统来说,要做到标记,不太易,要对每一个模块进行修改;为了不让修改太多的程序代码,做了如
下方法的修改:
1、在数据库中新建一个表MARK,该表与存储主数据表(ZPRO)中的字段一样;在工程部上传导入数据的同时,将保存一份同凭证的数据到MARK中。在各部门都维护完毕之后,工程部
导出数据时,将表ZPRO与表MARK同凭证数据进行配对,这样便可知道哪些数据是修改过的,对修改过的数据用样式数excel单元格字体用蓝色标记;这样工程部一看便知哪些数据是
更改过的。
相关程序代码如下:
POIFSFileSystem fs=new POIFSFileSystem(new   FileInputStream(cfname));  
                 HSSFWorkbook   wb   =   new   HSSFWorkbook(fs);  
               //  wb.removeSheetAt(2);  
                 HSSFSheet   sheet   =   wb.getSheetAt(0);  
                // sheet.setColumnWidth((short)200,(short)500);  
                 sheet.setColumnWidth((short)1, (short)4000);  //设置物料编号列的宽度
                 sheet.setColumnWidth((short)2, (short)12000); //设置物料描述列的宽度
                 sheet.setColumnWidth((short)4, (short)4000); // 设置图号列的宽度
                
                 HSSFFont hf=wb.createFont();
                 hf.setColor((short)4); //1:白色,2:红色,3:绿色,4:蓝色,5:黄色,6:紫色
                
                 HSSFCellStyle cs = wb.createCellStyle();              
                 cs.setBorderBottom((short)1);            //设置边框线
                 cs.setBorderLeft((short)1);
                 cs.setBorderRight((short)1);
                 cs.setBorderTop((short)1);
                
                 HSSFCellStyle css = wb.createCellStyle(); //此样式用来标识被改过的字段             
                 css.setBorderBottom((short)1);            //设置边框线
                 css.setBorderLeft((short)1);
                 css.setBorderRight((short)1);
                 css.setBorderTop((short)1);
                 css.setFont(hf);

for(int i=0;i                  Zpro cl=(Zpro)list.get(i);
                  Mark mr=(Mark)lism.get(i);
                  
                        HSSFRow row = sheet.getRow(i+4);
                        row = sheet.createRow(i+4);  
                       
                        HSSFCell cell=row.getCell((short)0);         //序号        
                        cell = row.createCell((short)0);
                        cell.setCellType(HSSFCell.CELL_TYPE_NUMERIC);  
                        cell.setCellValue(cl.getId().getNumbe());
                        cell.setCellStyle(cs);
                       
                        cell=row.getCell((short)1);                  //物料编号
                        cell = row.createCell((short)1);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(cl.getMatnr());
                        cell.setCellStyle(cs);
                       
                        cell=row.getCell((short)2);                  //物料描述1
                        cell = row.createCell((short)2);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(cl.getMaktx());
                        cell.setCellStyle(cs);
                       
                        cell=row.getCell((short)3);                  //物料描述2
                        cell = row.createCell((short)3);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getWrkst()));
                        cell.setCellStyle(cs);
                       
                        cell=row.getCell((short)4);                  //图号
                        cell = row.createCell((short)4);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getZeinr()));
                        cell.setCellStyle(cs);
                       
                        cell=row.getCell((short)5);                  //基本计量单位
                        cell = row.createCell((short)5);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getZeinr()));
                        cell.setCellStyle(cs);
                       
                        cell=row.getCell((short)6);                  //物料属性
                        cell = row.createCell((short)6);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getMtart()));
                        cell.setCellStyle(cs);
                       
                          cell=row.getCell((short)7);                     //价格控制
                        cell=row.createCell((short)7);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getVprsv()));
                        if((cl.getVprsv()).equals(mr.getVprsv())){
                         cell.setCellStyle(cs);
                        }else{
                         cell.setCellStyle(css);
                        }
                       
                        cell=row.getCell((short)8);                    //移动平均价
                        cell=row.createCell((short)8);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getVerpr()));
                        if((cl.getVerpr()).equals(mr.getVerpr())){
                         cell.setCellStyle(cs);
                        }else{
                         cell.setCellStyle(css);
                        }
                       
                        cell=row.getCell((short)9);                    //价格单位
                        cell=row.createCell((short)9);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getPeinh()));
                        if((cl.getPeinh()).equals(mr.getPeinh())){
                         cell.setCellStyle(cs);
                        }else{
                         cell.setCellStyle(css);
                        }
                       
                        cell=row.getCell((short)10);                    //商业价格
                        cell=row.createCell((short)10);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getBwprh()));
                        if((cl.getBwprh()).equals(mr.getBwprh())){
                         cell.setCellStyle(cs);
                        }else{
                         cell.setCellStyle(css);
                        }
                       
                        cell=row.getCell((short)11);                  //有无成本核算
                        cell=row.createCell((short)11);
                        cell.setCellType(HSSFCell.CELL_TYPE_STRING);  
                        cell.setCellValue(ChangeStr(cl.getNcost()));
                        if((cl.getNcost()).equals(mr.getNcost())){
                         cell.setCellStyle(cs);
                        }else{
                         cell.setCellStyle(css);
                        }
                 }
                 FileOutputStream   fileOut   =   new   FileOutputStream(cfname);  
                 wb.write(fileOut);  
                 fileOut.close();  
阅读(2179) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~