急100分求救 如何将jsp网页倒入到excel和world中 将jsp网页倒入到excel和world中?没听说过,只听说过jsp在网页使用excel和world 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 用notepad打开一个jsp文件,然后Ctrl+A并快速的按下Ctrl+C。然后打开一个word或者excel,鼠标在空白处点一下,然后Ctrl+V。就行了! package common;import java.io.*;import java.util.Vector;import org.apache.poi.hssf.usermodel.*;/*** <p>Title: </p>* <p>Description: </p>* <p>Copyright: Copyright (c) 2003</p>* <p>Company: MRO</p>* @author Kevin zhou* @version 1.0*/public class Excel {public void createExcelFile(ExcelIn excelIn) throws CommonException{Vector vtrData = excelIn.getData();HSSFWorkbook wb = new HSSFWorkbook();HSSFSheet sheet = wb.createSheet("Sheet1");setColumnWidth(sheet, excelIn.getWidth());HSSFFont font = wb.createFont();font.setFontName("宋体");HSSFCellStyle style = wb.createCellStyle();style.setFont(font);if(vtrData != null){Vector vtrTitle = excelIn.getTitle();HSSFRow rowTitle = sheet.createRow(0);for(int i=0;i<vtrTitle.size();i++){HSSFCell cell = rowTitle.createCell((short)i);cell.setEncoding(HSSFCell.ENCODING_UTF_16);cell.setCellValue((String)vtrTitle.get(i));cell.setCellStyle(style);}for(int i=0;i<vtrData.size();i++){HSSFRow row = sheet.createRow(i+1);Vector vtrRow = (Vector)vtrData.get(i);for(int j=0;j<vtrRow.size();j++){String strTemp = (String)vtrRow.get(j);if(" ".equals(strTemp)){strTemp = " ";}HSSFCell cell = row.createCell((short)j);cell.setEncoding(HSSFCell.ENCODING_UTF_16);cell.setCellValue(strTemp);cell.setCellStyle(style);}}}try{// Write the output to a fileFileOutputStream fileOut =new FileOutputStream(excelIn.getPath());wb.write(fileOut);fileOut.close();}catch(Exception e){throw new CommonException("文件已经打开,请关闭后再生成");}}/*** Set Column Width*/private void setColumnWidth(HSSFSheet sheet, int[] width){for(int i=0;i<width.length;i++){sheet.setColumnWidth((short)i, (short)(width[i]*256));}}}package common;import java.util.Vector;/*** <p>Title: </p>* <p>Description: </p>* <p>Copyright: Copyright (c) 2003</p>* <p>Company: MRO</p>* @author Kouken* @version 1.0*/public class ExcelIn {private String path = null;Vector vtrData = null; // vector->vector->StringVector vtrTitle = null; // vector->Stringint width[];public String getPath(){return this.path;}public void setPath(String path){this.path = path;}public Vector getData(){return this.vtrData;}public void setData(Vector vtrData){this.vtrData = vtrData;}public Vector getTitle(){return this.vtrTitle;}public void setTitle(Vector vtrTitle){this.vtrTitle = vtrTitle;}public int[] getWidth(){return this.width;}public void setWidth(int width[]){this.width = width;}} antlr-2.7.2.jar和antlr-2.7.6.jar冲突,前一个jar包删除项目无法启动 struts2 404错误 关于JSP中popUpWindow弹出窗口的问题? jsp的页面跳转 url能传对象吗 java中如何实现嗅探器?将网卡模式改为混杂模式? highcharts 柱状图问题 如何实现视频点播 我的JSP代码为什么去掉该行注释后就出错? 问一个关于浮点数的问题 我有很多JSP的电子书,要的话,请留下email ssl與cookie會出現過期的問題,幫幫手!
import java.util.Vector;
import org.apache.poi.hssf.usermodel.*;/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: MRO</p>
* @author Kevin zhou
* @version 1.0
*/public class Excel {
public void createExcelFile(ExcelIn excelIn) throws CommonException{
Vector vtrData = excelIn.getData();HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Sheet1");setColumnWidth(sheet, excelIn.getWidth());HSSFFont font = wb.createFont();
font.setFontName("宋体");HSSFCellStyle style = wb.createCellStyle();
style.setFont(font);if(vtrData != null){
Vector vtrTitle = excelIn.getTitle();
HSSFRow rowTitle = sheet.createRow(0);
for(int i=0;i<vtrTitle.size();i++){
HSSFCell cell = rowTitle.createCell((short)i);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue((String)vtrTitle.get(i));
cell.setCellStyle(style);
}for(int i=0;i<vtrData.size();i++){
HSSFRow row = sheet.createRow(i+1);
Vector vtrRow = (Vector)vtrData.get(i);
for(int j=0;j<vtrRow.size();j++){
String strTemp = (String)vtrRow.get(j);
if(" ".equals(strTemp)){
strTemp = " ";
}HSSFCell cell = row.createCell((short)j);
cell.setEncoding(HSSFCell.ENCODING_UTF_16);
cell.setCellValue(strTemp);
cell.setCellStyle(style);
}
}
}try{
// Write the output to a file
FileOutputStream fileOut =
new FileOutputStream(excelIn.getPath());
wb.write(fileOut);
fileOut.close();
}catch(Exception e){
throw new CommonException("文件已经打开,请关闭后再生成");
}
}/**
* Set Column Width
*/
private void setColumnWidth(HSSFSheet sheet, int[] width){
for(int i=0;i<width.length;i++){
sheet.setColumnWidth((short)i, (short)(width[i]*256));
}
}
}
package common;import java.util.Vector;
/**
* <p>Title: </p>
* <p>Description: </p>
* <p>Copyright: Copyright (c) 2003</p>
* <p>Company: MRO</p>
* @author Kouken
* @version 1.0
*/public class ExcelIn {
private String path = null;Vector vtrData = null; // vector->vector->String
Vector vtrTitle = null; // vector->String
int width[];public String getPath(){
return this.path;
}public void setPath(String path){
this.path = path;
}public Vector getData(){
return this.vtrData;
}public void setData(Vector vtrData){
this.vtrData = vtrData;
}public Vector getTitle(){
return this.vtrTitle;
}public void setTitle(Vector vtrTitle){
this.vtrTitle = vtrTitle;
}public int[] getWidth(){
return this.width;
}public void setWidth(int width[]){
this.width = width;
}}