如果通过单击按扭生成文件?
我想在网页上单击按扭,就会把刚才从数据库查询到的数据导入到excel里面去,请问这怎么实现?
------解决方案--------------------看看下面这段程序:
public static HSSFWorkbook highlightExcel_view(Vector tmpVector, String excel_flag) throws Exception {
String empno= " ";
String user_id= " ";
String full_name= " ";
String app_id= " ";
String excel_subject = " ";
HSSFWorkbook wb = new HSSFWorkbook();
if( "terminate ".equals(excel_flag))
excel_subject = "Terminate User List ";
HSSFSheet sheet1 = wb.createSheet(excel_subject);
HSSFRow row = null;
HSSFCell cell = null;
HSSFCellStyle cellBorderBoldStyle= wb.createCellStyle();
HSSFCellStyle cellBoldStyle= wb.createCellStyle();
HSSFCellStyle cellBorderStyle= wb.createCellStyle();
HSSFCellStyle cellStyle= wb.createCellStyle();
HSSFFont boldFont = wb.createFont();
HSSFFont font = wb.createFont();
boldFont.setBoldweight(HSSFFont.BOLDWEIGHT_BOLD);
cellBoldStyle.setFont(boldFont);
cellBorderStyle.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellBorderStyle.setBottomBorderColor(HSSFColor.BLACK.index);
cellBorderStyle.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellBorderStyle.setLeftBorderColor(HSSFColor.BLACK.index);
cellBorderStyle.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellBorderStyle.setRightBorderColor(HSSFColor.BLACK.index);
cellBorderStyle.setBorderTop(HSSFCellStyle.BORDER_THIN);
cellBorderStyle.setTopBorderColor(HSSFColor.BLACK.index);
// start writing on sheet 1 (transfer in )
// row 0
row = sheet1.createRow((short)0);
if( "terminate ".equals(excel_flag)){
cell = FieldData.createStringCell(row, 0, "Terminate User Account List ", cellBoldStyle);
// row1
row = sheet1.createRow((short)1);
cell = FieldData.createStringCell(row, 0, "Emp NO. ", cellBoldStyle);
cell = FieldData.createStringCell(row, 1, "Full Name ", cellBoldStyle);
cell = FieldData.createStringCell(row, 2, "Terminate Date ", cellBoldStyle);
cell = FieldData.createStringCell(row, 3, "User Id ", cellBoldStyle);
cell = FieldData.createStringCell(row, 4, "Appcation ", cellBoldStyle);
}
sheet1.addMergedRegion(new Region(0,(short)0, 0,(short)0));
for(int j=0;j <tmpVector.size();j++){
row = sheet1.createRow((short)(j+2));
for(int k=0; k < ((Vector)tmpVector.get(j)).size()-3; k++)
cell = FieldData.createStringCell(row, k,((Vector)tmpVector.get(j)).get(k).toString(), cellBorderStyle);
sheet1.addMergedRegion(new Region(0,(short)0, 0,(short)2));
}
return wb;
}
------解决方案--------------------这个你得找有第三方jar包
基本上都有例子的
比较简单
"利用JAVA操作EXCEL文件(JAVA EXCEL API) "
http://www.88doc.com/88doc/software/java/2/2_1168879968090.html
------解决方案--------------------写个ActiveX控件,调用其方法,把文件生成在IE的零食目录下面,生成完后打开它
------解决方案------------------