`

Bugzilla Bug Xml导出为excel

阅读更多

下面是我做一个程序:用java语言将Bugzilla系统的Bug Xml转化为excel文件。

 

用java处理excel文件的第三方包: pio-3.7-20101029.jar

 

主要代码:

 

读取Xml:

 

package com.tzp.bugzilla;

import java.io.File;
import java.util.ArrayList;
import java.util.List;

import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node;
import org.w3c.dom.NodeList;



public class ReadXml {

	
	
	public List<Bug> GetBugList(String xmlPath) throws Exception{
		
		DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
		DocumentBuilder builder;
		builder = factory.newDocumentBuilder();
		
		File file=new File(xmlPath);
		
		//boolean b=file.exists(); 
		
		//System.out.println(b); 
		
		Document document = builder.parse(file);
		
		Element e1=document.getDocumentElement();
		
		NodeList nodeList=e1.getChildNodes();
		
		List<Bug> bugList=new ArrayList<Bug>();
		
		for(int i=0;i<nodeList.getLength();i++){
			Node bugNode=nodeList.item(i);
			if("bug".equalsIgnoreCase(bugNode.getNodeName())){
				Element bugEle=(Element)bugNode;
				Bug bug=GetBugInfor(bugEle);
				bugList.add(bug);
			};
		}
				
		return bugList;
	}
	
	public Bug GetBugInfor(Element e){
		
		Bug bug =new Bug();
		
		bug.setBug_ID(e.getElementsByTagName("bug_id").item(0).getTextContent());
		bug.setBug_opened_time(e.getElementsByTagName("creation_ts").item(0).getTextContent());
		bug.setBug_summary(e.getElementsByTagName("short_desc").item(0).getTextContent());
		bug.setBug_changed_time(e.getElementsByTagName("delta_ts").item(0).getTextContent());
		bug.setBug_product(e.getElementsByTagName("product").item(0).getTextContent());
		bug.setBug_comp(e.getElementsByTagName("component").item(0).getTextContent());
		bug.setBug_version(e.getElementsByTagName("version").item(0).getTextContent());
		bug.setBug_hardware(e.getElementsByTagName("rep_platform").item(0).getTextContent());
		bug.setBug_OS(e.getElementsByTagName("op_sys").item(0).getTextContent());
		bug.setBug_status(e.getElementsByTagName("bug_status").item(0).getTextContent());
		bug.setBug_priority(e.getElementsByTagName("priority").item(0).getTextContent());
		bug.setBug_severity(e.getElementsByTagName("bug_severity").item(0).getTextContent());
		bug.setBug_reporter(e.getElementsByTagName("reporter").item(0).getTextContent());		
		bug.setBug_reporter_realname(((Element)e.getElementsByTagName("reporter").item(0)).getAttribute("name"));	
		bug.setBug_assign(e.getElementsByTagName("assigned_to").item(0).getTextContent());
		bug.setBug_assign_realname(((Element)e.getElementsByTagName("assigned_to").item(0)).getAttribute("name"));
		
		//bug.setBug_frequency(e.getElementsByTagName("cf_frequency").item(0).getTextContent());
		
		if(e.getElementsByTagName("cf_language").getLength()==0){
			bug.setBug_language("");
		}else{
			bug.setBug_language(e.getElementsByTagName("cf_language").item(0).getTextContent());
		}
		if(e.getElementsByTagName("cf_frequency").getLength()==0){
			bug.setBug_frequency("");
		}else{
			bug.setBug_frequency(e.getElementsByTagName("cf_frequency").item(0).getTextContent());			
		}
		
		if(e.getElementsByTagName("resolution").getLength()==0){
			bug.setBug_resolution("");
		}else{
			bug.setBug_resolution(e.getElementsByTagName("resolution").item(0).getTextContent());
		}
		
		//读取desc 
		NodeList descList=e.getElementsByTagName("long_desc");
		String comments="";
		String desc="";
		for(int i=0;i<descList.getLength();i++){
			Element descEle=(Element)descList.item(i);
			//将第一个desc设置为Reproduce steps and test results,将其它desc设置为comments
			if(i==0){
				desc=descEle.getElementsByTagName("thetext").item(0).getTextContent(); 
			}else{
				comments=comments +descEle.getElementsByTagName("bug_when").item(0).getTextContent()+" "
				+((Element)descEle.getElementsByTagName("who").item(0)).getAttribute("name")+" : \n"
				+descEle.getElementsByTagName("thetext").item(0).getTextContent()+"\n";
			}
		}	
		bug.setBug_desc(desc);
		bug.setBug_comments(comments);
					
		return bug;
	}
	
	public void PrintBugList(List<Bug> bugList){
		for(Bug bug:bugList){
			System.out.println(bug);
		}
	}
}
写入Excel文件代码:
package com.tzp.bugzilla;
import java.io.FileOutputStream;
import java.util.List;
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFFont;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Font;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.apache.poi.ss.usermodel.Workbook;
import org.apache.poi.ss.util.CellRangeAddress;
public class WriteToExcel {
 private Workbook wb=null;
 private Sheet sh=null;
 private CellStyle defStyle=null;
 private CellStyle defStyle1=null;
 private Font redFont=null;
 private Font blackFont=null;
 
 private int ID=0;
 private int id_Id=0;
 private int product_Id=0;
 private int version_Id=0;
 private int assign_Id=0;
 private int severity_Id=0;
 private int hardware_Id=0;
 private int OS_Id=0;
 private int priority_Id=0;
 private int frequency_Id=0;
 private int language_Id=0;
 private int reopen_version_Id=0;
 private int close_version_Id=0;
 private int summary_Id=0;
 private int desc_Id=0;
 private int comments_Id=0;
 private int opened_time_Id=0;
 private int changed_time_Id=0;
 private int comp_Id=0;
 private int status_Id=0;
 private int assign_realname_Id=0;
 private int reporter_Id=0;
 private int reporter_realname_Id=0;
 private int resolution_id=0;
 
 public void writeBug(List<Bug> list,String strPath,SelectInfor sInfor) throws Exception{
  
  //set excel style , width ,titles
  writeTitle(sInfor);
  
  int intNum=2;
  
  for(int i=0;i<list.size();i++){
   
   Bug bug=list.get(i);
   //定义sheet的列默认style:水平居中,垂直居中,画出边框线
   defStyle=wb.createCellStyle();
   defStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
   defStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
   defStyle.setWrapText(true);//自动换行
   
   defStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
   defStyle.setBottomBorderColor(HSSFColor.BLACK.index);
   defStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
   defStyle.setLeftBorderColor(HSSFColor.BLACK.index);
   defStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
   defStyle.setRightBorderColor(HSSFColor.BLACK.index);
   defStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
   defStyle.setTopBorderColor(HSSFColor.BLACK.index);  
   
   //定义sheet的列默认style:水平靠左,垂直居中,画出边框线
   defStyle1=wb.createCellStyle();
   defStyle1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
   defStyle1.setAlignment(HSSFCellStyle.ALIGN_LEFT);
   defStyle1.setWrapText(true);//自动换行
   
   defStyle1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
   defStyle1.setBottomBorderColor(HSSFColor.BLACK.index);
   defStyle1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
   defStyle1.setLeftBorderColor(HSSFColor.BLACK.index);
   defStyle1.setBorderRight(HSSFCellStyle.BORDER_THIN);
   defStyle1.setRightBorderColor(HSSFColor.BLACK.index);
   defStyle1.setBorderTop(HSSFCellStyle.BORDER_THIN);
   defStyle1.setTopBorderColor(HSSFColor.BLACK.index);
   
   //判断是否为critical bug 和blocker bug,用红色字体
   if(bug.getBug_severity().equalsIgnoreCase("critical") || bug.getBug_severity().equalsIgnoreCase("blocker")){
    defStyle.setFont(redFont);
    defStyle1.setFont(redFont);
    //System.out.println("*******");
   }else{
    defStyle.setFont(blackFont);
    defStyle1.setFont(blackFont);
    //System.out.println("++++++");
   }
   
   Row row=sh.createRow(intNum);
   if(sInfor.isId()){
    Cell cellId=row.createCell(this.id_Id);
    cellId.setCellValue(bug.getBug_ID());
    cellId.setCellStyle(defStyle);
   }
   if(sInfor.isStatus()){
    Cell cellStatus=row.createCell(this.status_Id);
    cellStatus.setCellValue(bug.getBug_status());
    cellStatus.setCellStyle(defStyle);
   }
   if(sInfor.isResolution()){
    Cell cellStatus=row.createCell(this.resolution_id);
    cellStatus.setCellValue(bug.getBug_resolution());
    cellStatus.setCellStyle(defStyle);
   }
   if(sInfor.isPriority()){
    Cell cellPriority=row.createCell(this.priority_Id);
    cellPriority.setCellValue(bug.getBug_priority());
    cellPriority.setCellStyle(defStyle);
   }
   if(sInfor.isSeverity()){
    Cell cellSeverity=row.createCell(this.severity_Id);
    cellSeverity.setCellValue(bug.getBug_severity());
    cellSeverity.setCellStyle(defStyle);
   }
   if(sInfor.isProduct()){
    Cell cellProduct=row.createCell(this.product_Id);
    cellProduct.setCellValue(bug.getBug_product());
    cellProduct.setCellStyle(defStyle);
   }
   if(sInfor.isOS()){
    Cell cellOS=row.createCell(this.OS_Id);
    cellOS.setCellValue(bug.getBug_OS());
    cellOS.setCellStyle(defStyle);
   }
   if(sInfor.isHardware()){
    Cell cellHardware=row.createCell(this.hardware_Id);
    cellHardware.setCellValue(bug.getBug_hardware());
    cellHardware.setCellStyle(defStyle);
   }
   if(sInfor.isComp()){
    Cell cellComp=row.createCell(this.comp_Id);
    cellComp.setCellValue(bug.getBug_comp());
    cellComp.setCellStyle(defStyle);
   }
   if(sInfor.isSummary()){
    Cell cellSummary=row.createCell(this.summary_Id);
    cellSummary.setCellValue(bug.getBug_summary());
    cellSummary.setCellStyle(defStyle1);
   }
   if(sInfor.isDesc()){
    Cell cellDesc=row.createCell(this.desc_Id);
    cellDesc.setCellValue(bug.getBug_desc());
    cellDesc.setCellStyle(defStyle1);
   }
   if(sInfor.isFrequency()){
    Cell cellFrequency=row.createCell(this.frequency_Id);
    cellFrequency.setCellValue(bug.getBug_frequency());
    cellFrequency.setCellStyle(defStyle);
   }
   if(sInfor.isVersion()){
    Cell cellVersion=row.createCell(this.version_Id);
    cellVersion.setCellValue(bug.getBug_version());
    cellVersion.setCellStyle(defStyle);
   }
   if(sInfor.isLanguage()){
    Cell cellLanguage=row.createCell(this.language_Id);
    cellLanguage.setCellValue(bug.getBug_language());
    cellLanguage.setCellStyle(defStyle);
   }
   if(sInfor.isReporter_realname()){
    Cell cellReporterRealName=row.createCell(this.reporter_realname_Id);
    cellReporterRealName.setCellValue(bug.getBug_reporter_realname());
    cellReporterRealName.setCellStyle(defStyle);
   }
   if(sInfor.isOpened_time()){
    Cell cellOpened=row.createCell(this.opened_time_Id);
    cellOpened.setCellValue(bug.getBug_opened_time());
    cellOpened.setCellStyle(defStyle);
   }
   if(sInfor.isReporter()){
    Cell cellReporter=row.createCell(this.reporter_Id);
    cellReporter.setCellValue(bug.getBug_reporter());
    cellReporter.setCellStyle(defStyle);
   }
   if(sInfor.isAssign_realname()){
    Cell cellAssignRealName=row.createCell(this.assign_realname_Id);
    cellAssignRealName.setCellValue(bug.getBug_assign_realname());
    cellAssignRealName.setCellStyle(defStyle);
   }
   if(sInfor.isAssign()){
    Cell cellAssign=row.createCell(this.assign_Id);
    cellAssign.setCellValue(bug.getBug_assign());
    cellAssign.setCellStyle(defStyle);
   }
   if(sInfor.isChanged_time()){
    Cell cellChanged=row.createCell(this.changed_time_Id);
    cellChanged.setCellValue(bug.getBug_changed_time());
    cellChanged.setCellStyle(defStyle);
   }
   if(sInfor.isComments()){
    Cell cellComments=row.createCell(this.comments_Id);
    cellComments.setCellValue(bug.getBug_comments());
    cellComments.setCellStyle(defStyle1);
   }
   if(sInfor.isReopen_version()){
    Cell cellReopenVersion=row.createCell(this.reopen_version_Id);
    cellReopenVersion.setCellValue(bug.getBug_reopen_version());
    cellReopenVersion.setCellStyle(defStyle);
   }
   if(sInfor.isClose_version()){
    Cell cellClosed=row.createCell(this.close_version_Id);
    cellClosed.setCellValue(bug.getBug_close_version());
    cellClosed.setCellStyle(defStyle);
   }
   
      intNum++;
  }
  
  //output excel file
  OutputExcel(strPath);
 }
 
 
 public void writeTitle(SelectInfor sInfor){
  
  //new excel
  wb=new HSSFWorkbook(); 
  //new sheet
  sh=wb.createSheet();
  //set sheet name
  wb.setSheetName(0, "Bug List");
  
  //定义red font
  redFont=wb.createFont();
  redFont.setColor(HSSFColor.RED.index);
  
  //define black font
  blackFont=wb.createFont();
  blackFont.setColor(HSSFColor.BLACK.index);
  /*
  //定义sheet的列默认style:水平居中,垂直居中,画出边框线
  defStyle=wb.createCellStyle();
  defStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  defStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  defStyle.setWrapText(true);//自动换行
  
  defStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  defStyle.setBottomBorderColor(HSSFColor.BLACK.index);
  defStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  defStyle.setLeftBorderColor(HSSFColor.BLACK.index);
  defStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
  defStyle.setRightBorderColor(HSSFColor.BLACK.index);
  defStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
  defStyle.setTopBorderColor(HSSFColor.BLACK.index);  
  
  //定义sheet的列默认style:水平靠左,垂直居中,画出边框线
  defStyle1=wb.createCellStyle();
  defStyle1.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  defStyle1.setAlignment(HSSFCellStyle.ALIGN_LEFT);
  defStyle1.setWrapText(true);//自动换行
  
  defStyle1.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  defStyle1.setBottomBorderColor(HSSFColor.BLACK.index);
  defStyle1.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  defStyle1.setLeftBorderColor(HSSFColor.BLACK.index);
  defStyle1.setBorderRight(HSSFCellStyle.BORDER_THIN);
  defStyle1.setRightBorderColor(HSSFColor.BLACK.index);
  defStyle1.setBorderTop(HSSFCellStyle.BORDER_THIN);
  defStyle1.setTopBorderColor(HSSFColor.BLACK.index);
  */
  
  //new title row
  Row row0=sh.createRow(0);
  row0.setHeightInPoints(35);
  Cell cellTitle=row0.createCell(0);
  cellTitle.setCellValue("Bug List Report");
  
  //定义title style
  CellStyle titleStyle=wb.createCellStyle();
  titleStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
  titleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);
  
  titleStyle.setFillForegroundColor(HSSFColor.GREEN.index);
  titleStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
  titleStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  titleStyle.setBottomBorderColor(HSSFColor.BLACK.index);
  titleStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  titleStyle.setLeftBorderColor(HSSFColor.BLACK.index);
  titleStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
  titleStyle.setRightBorderColor(HSSFColor.BLACK.index);
  titleStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
  titleStyle.setTopBorderColor(HSSFColor.BLACK.index);  
  
  Font titleFont=wb.createFont();
  titleFont.setFontHeightInPoints((short)16);
  titleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
  titleStyle.setFont(titleFont);
  //设置Title row 的style
  cellTitle.setCellStyle(titleStyle);
  
  //设第2行的style
  CellStyle rowTitleStyle=wb.createCellStyle();
  rowTitleStyle.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);//垂直居中
  rowTitleStyle.setAlignment(HSSFCellStyle.ALIGN_CENTER);//水平居中
  //设置背景颜色为浅橙色
  rowTitleStyle.setFillForegroundColor(HSSFColor.LIGHT_ORANGE.index);
  rowTitleStyle.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);
    
  rowTitleStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
  rowTitleStyle.setBottomBorderColor(HSSFColor.BLACK.index);
  rowTitleStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
  rowTitleStyle.setLeftBorderColor(HSSFColor.BLACK.index);
  rowTitleStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
  rowTitleStyle.setRightBorderColor(HSSFColor.BLACK.index);
  rowTitleStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
  rowTitleStyle.setTopBorderColor(HSSFColor.BLACK.index);
  
  Font rowTitleFont=wb.createFont();
  rowTitleFont.setFontHeightInPoints((short)10);  //字体10号
  rowTitleFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);//加粗
  
  rowTitleStyle.setFont(rowTitleFont);
  
  //new second row
  Row row=sh.createRow(1);
  row.setHeightInPoints(25);
  //是否有选择ID
  if(sInfor.isId()){  
   this.id_Id=ID;
   sh.setColumnWidth(this.id_Id, 8*256);
   // new Bug ID cell
   Cell cellId=row.createCell(id_Id);
   cellId.setCellValue("Bug ID");
   cellId.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isStatus()){
   this.status_Id=ID;
   sh.setColumnWidth(this.status_Id, 12*256);
   // new Status cell
   Cell cellStatus=row.createCell(status_Id);
   cellStatus.setCellValue("Status");
   cellStatus.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isResolution()){
   this.resolution_id=ID;
   sh.setColumnWidth(this.resolution_id, 12*256);
   // new Status cell
   Cell cellStatus=row.createCell(resolution_id);
   cellStatus.setCellValue("Resolution");
   cellStatus.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isPriority()){
   this.priority_Id=ID;
   sh.setColumnWidth(this.priority_Id, 10*256);
   // new Priority cell
   Cell cellPriority=row.createCell(priority_Id);
   cellPriority.setCellValue("Priority");
   cellPriority.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isSeverity()){
   this.severity_Id=ID;
   sh.setColumnWidth(this.severity_Id, 10*256);
   // new severity cell
   Cell cellSeverity=row.createCell(severity_Id);
   cellSeverity.setCellValue("Severity");
   cellSeverity.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isProduct()){
   this.product_Id=ID;
   sh.setColumnWidth(this.product_Id, 12*256);
   // new product cell
   Cell cellProduct=row.createCell(product_Id);
   cellProduct.setCellValue("Product");
   cellProduct.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isOS()){
   this.OS_Id=ID;
   sh.setColumnWidth(this.OS_Id, 12*256);
   // new OS cell
   Cell cellOS=row.createCell(OS_Id);
   cellOS.setCellValue("OS");
   cellOS.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isHardware()){
   this.hardware_Id=ID;
   sh.setColumnWidth(this.hardware_Id, 12*256);
   // new Hardware cell
   Cell cellHardware=row.createCell(hardware_Id);
   cellHardware.setCellValue("Hardware");
   cellHardware.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isComp()){
   this.comp_Id=ID;
   sh.setColumnWidth(this.comp_Id, 12*256);
   // new Component cell
   Cell cellComp=row.createCell(comp_Id);
   cellComp.setCellValue("Component");
   cellComp.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isSummary()){
   this.summary_Id=ID;
   sh.setColumnWidth(this.summary_Id, 60*256);
   // new Summary cell
   Cell cellSummary=row.createCell(summary_Id);
   cellSummary.setCellValue("Summary");
   cellSummary.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isDesc()){
   this.desc_Id=ID;
   sh.setColumnWidth(this.desc_Id, 60*256);
   // new Description cell
   Cell cellDesc=row.createCell(desc_Id);
   cellDesc.setCellValue("Detail Description");
   cellDesc.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isFrequency()){
   this.frequency_Id=ID;
   sh.setColumnWidth(this.frequency_Id, 10*256);
   // new Frequency cell
   Cell cellFrequency=row.createCell(frequency_Id);
   cellFrequency.setCellValue("Frequency");
   cellFrequency.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isVersion()){
   this.version_Id=ID;
   sh.setColumnWidth(this.version_Id, 15*256);
   // new severity cell
   Cell cellVersion=row.createCell(version_Id);
   cellVersion.setCellValue("Version");
   cellVersion.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isLanguage()){
   this.language_Id=ID;
   sh.setColumnWidth(this.language_Id, 15*256);
   // new language cell
   Cell cellLanguage=row.createCell(language_Id);
   cellLanguage.setCellValue("language");
   cellLanguage.setCellStyle(rowTitleStyle);
   
   ID++;
  }
  if(sInfor.isReporter_realname()){
   this.reporter_realname_Id=ID;
   sh.setColumnWidth(this.reporter_realname_Id, 20*256);
   // new Reporter real name cell
   Cell cellReporterRealName=row.createCell(reporter_realname_Id);
   cellReporterRealName.setCellValue("Reporter");
   cellReporterRealName.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isOpened_time()){
   this.opened_time_Id=ID;
   sh.setColumnWidth(this.opened_time_Id, 20*256);
   // new Opened time cell
   Cell cellOpened=row.createCell(opened_time_Id);
   cellOpened.setCellValue("Opened");
   cellOpened.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isReporter()){
   this.reporter_Id=ID;
   sh.setColumnWidth(this.reporter_Id, 20*256);
   // new Reporter cell
   Cell cellReporter=row.createCell(reporter_Id);
   cellReporter.setCellValue("Report Email");
   cellReporter.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isAssign_realname()){
   this.assign_realname_Id=ID;
   sh.setColumnWidth(this.assign_realname_Id, 20*256);
   // new assign real name cell
   Cell cellAssignRealName=row.createCell(assign_realname_Id);
   cellAssignRealName.setCellValue("Assign");
   cellAssignRealName.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isAssign()){
   this.assign_Id=ID;
   sh.setColumnWidth(this.assign_Id, 20*256);
   // new assign cell
   Cell cellAssign=row.createCell(assign_Id);
   cellAssign.setCellValue("Assign Email");
   cellAssign.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isChanged_time()){
   this.changed_time_Id=ID;
   sh.setColumnWidth(this.changed_time_Id, 20*256);
   // new severity cell
   Cell cellChanged=row.createCell(changed_time_Id);
   cellChanged.setCellValue("Changed");
   cellChanged.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isComments()){
   this.comments_Id=ID;
   sh.setColumnWidth(this.comments_Id, 60*256);
   // new comments cell
   Cell cellComments=row.createCell(comments_Id);
   cellComments.setCellValue("Comments");
   cellComments.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isReopen_version()){
   this.reopen_version_Id=ID;
   sh.setColumnWidth(this.reopen_version_Id, 20*256);
   // new severity cell
   Cell cellReopened=row.createCell(reopen_version_Id);
   cellReopened.setCellValue("Reopen version");
   cellReopened.setCellStyle(rowTitleStyle);
   ID++;
  }
  if(sInfor.isClose_version()){
   this.close_version_Id=ID;
   sh.setColumnWidth(this.close_version_Id, 20*256);
   // new severity cell
   Cell cellClosed=row.createCell(close_version_Id);
   cellClosed.setCellValue("Close version");
   cellClosed.setCellStyle(rowTitleStyle);
   ID++;
  }
   
  //合并第一行单元格
  sh.addMergedRegion(new CellRangeAddress(0,0,0,ID-1));
  
 }
 
 /**
  * 将workbokk 通过fileOutputStream输入为excel文件
  * @param wb
  */
 public void OutputExcel(String strPath) throws Exception{
  FileOutputStream fileOut =null;  
  try{
   fileOut=new FileOutputStream(strPath);   
   wb.write(fileOut);   
  } finally{
   if(fileOut!=null){    
     fileOut.close();
   }   
  }
 }
}

 

分享到:
评论

相关推荐

    bugzilla中导出的BUG列表查看方法

    到处CSV文档并转换为microsoft windows 下可以查看的excel文档。

    Bugzilla一个易用、高效的bug跟踪工具

    开发者可以免费下载Bugzilla,他们需要一个易用、高效的bug跟踪工具,现在有很多这样的工具。 Bugzilla就是其中之一。 它是Mozilla的跟踪工具,可以用来跟踪和报告网络和应用程序上的错误和错误。 安装说明:...

    Bugzilla

    Bugzilla bug 跟踪系统

    bugzilla的搭建详解

    Bugzilla搭建文档,本文以官方英文文档为基础编写。文中提供了所需软件的下载地址。 Bugzilla是一个Bug的管理平台。它让用户报告软件的Bug而且把它们转给合适的开发者。开发者能使用bugzilla保持一个要做的事情的...

    Bugzilla开发趋势分析工具

    Bugzilla开发趋势分析工具。通过Bugzilla数据分析当前项目开发情况,bug收敛情况,并生成图表。主要面向Team leader和测试人员随时掌握项目研发进度。纯windows应用,无需安装任何插件和语言包。

    bugzilla使用说明

    导出cvs格式的表格,通过excel打开时,中文会显示乱码,因为bugzill是utf8的编码,在excel中不支持,就是把csv文件转成ascii码就能正常显示的,具体是将cvs文档用记事本或utraledit打开,另存为,格式中选择"ANSI/...

    bztotj:将 Bugzilla 错误导出到 TaskJuggler 项目

    将 Bugzilla 错误导出到 TaskJuggler 项目。 用法 将错误导出到 TaskJuggler 包含文件: bztotj.py MILESTONE [MILESTONE...] 这将创建文件“bugzilla_flags.tji”、“bugzilla_project.tji”、“MILESTONE_...

    开源软件bug管理工具bugzilla-3.0.4.tar.gz

    开源软件bug管理工具bugzilla-3.0.4.tar.gz

    Bug跟踪管理软件bugzilla

    较好的一款用于Bug跟踪管理的软件 它可以管理软件开发中缺陷的提交(new),修复(resolve),关闭(close)等整个生命周期。

    Bugzilla使用实例

    一个详细的,权威的Bugzilla教程,内容是一个公司总结的使用手册,对Bugzilla的英文术语都有相应的注释。并且图文并茂,适合于初学者,也适合于有一定经验的测试人员的深入理解 ,下了你不会后悔

    windows 下Bugzilla 安装指南

    bugzilla 安装指南,文档包含内容: 安装、配置MySQL ,安装IIS,安装ActivePerl,安装bugzilla ,配置IIs ,配置bugzilla

    Bugzilla5.0中文语言包

    Bugzilla 中文包,解压后放到template文件夹下即可!亲测可用!

    在 Linux 上使用 Bugzilla 跟踪 bug

    Bugzilla 是一个缺陷或bug 跟踪系统 —— 这个系统能够让个人或者团队开发人员保持对他们的产品中突出 bug 的跟踪。此类系统允许用户跟踪 bug 和代码修改,与其他队友沟通,提交和回顾修订补丁,实现质量保证。 ...

    bugzilla-3.6.2

    Bugzilla是一开源Bug Tracking System,是专门为Unix定制开发的。但是在windows平台下依然可以成功安装使用. Testopia是一款和Bugzilla集成到一起的test case management系统. 国内配置管理之路有Bugzilla版面,可以...

    Bugzilla for windows(1)

    Bugzilla for windows Windows下安装Bugzilla bug管理工具的整套东西。 包括安装说明。 收取点收工劳务费,^_^ .

    bugzilla使用简明手册.doc

    作为一个产品缺陷的记录及跟踪工具,它能够为你建立一个完善的Bug跟踪体系,包括报告Bug、查询Bug记录并产生报表、处理解决、管理员系统初始化和设置四部分。并具有如下特点:  基于Web方式,安装简单、运行方便...

    BUGZILLA教程

    BUGZILLA学习的最佳文档。结合测试原理详细介绍了BUGZILLA的工作流程。为BUGZILLA初学者提供最佳支持。

    Bugzilla的简单介绍

    具,它能够为你建立一个完善的Bug跟踪体系,包括报告Bug、查询Bug记录并产生报表、处理解决、管理员 系统初始化和设置四部分。并具有如下特点: 1.基于Web方式,安装简单、运行方便快捷、管理安全。 2.有利于缺陷...

    Bugzilla for windows(3)

    Bugzilla for windows Windows下安装Bugzilla bug管理工具的整套东西。 包括安装说明。 收取点收工劳务费,^_^ .

Global site tag (gtag.js) - Google Analytics