91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 2KB
    文件類型: .zip
    金幣: 2
    下載: 0 次
    發布日期: 2021-05-28
  • 語言: Java
  • 標簽: 源碼??工具??

資源簡介

NULL 博文鏈接:https://liushuoa.iteye.com/blog/2376548

資源截圖

代碼片段和文件信息

package?com.aisino.sjfx.utils;

import?java.io.File;
import?java.io.FileOutputStream;
import?java.io.IOException;
import?java.io.OutputStream;
import?java.text.DecimalFormat;
import?java.text.SimpleDateFormat;
import?java.util.Date;
import?java.util.List;
import?java.util.Map;

import?javax.servlet.http.HttpServletRequest;
import?javax.servlet.http.HttpServletResponse;

import?org.apache.poi.hssf.usermodel.HSSFCell;
import?org.apache.poi.hssf.usermodel.HSSFCellstyle;
import?org.apache.poi.hssf.usermodel.HSSFFont;
import?org.apache.poi.hssf.usermodel.HSSFRichTextString;
import?org.apache.poi.hssf.usermodel.HSSFRow;
import?org.apache.poi.hssf.usermodel.HSSFSheet;
import?org.apache.poi.hssf.usermodel.HSSFWorkbook;
import?org.apache.poi.hssf.util.CellRangeAddress;
import?org.apache.poi.hssf.util.HSSFColor;

public?class?ExportExcelUtil?{

/**
?*?你下載指定的文件名需帶擴展名
?*?
?*?@param?fileName
?*?
?*?@param?response
?*?
?*????????????mybatis返回的數據源的封裝?例如:Listject>>
?*?@param?dataset
?*?
?*????????????每一個sheet顯示的標題
?*?@param?headerss
?*?
?*????????????你sql語句select的column?的name要和header對應
?*?@param?keys
?*?
?*????????????頁腳顯示的文字
?*?@param?sheets
?*/
@SuppressWarnings(“rawtypes“)
public?static?String?exportExcel(String?realpathString?headNameString?fileName
HttpServletResponse?response?List?dataset
String[][]?headerss?String[][]?keys)?{
String?excelFile?=?realpath+fileName;
try?{
/**
?*?建立一個導出excel工程
?*/
HSSFWorkbook?workbook?=?new?HSSFWorkbook();

//?設置標題單元格樣式?和?標題的字體
HSSFCellstyle?style?=?configCellstyle(workbook);
//?設置內容單元格樣式?和?內容的字體
HSSFCellstyle?style2?=?configContentstyle(workbook);
//?設置第一行樣式
HSSFCellstyle?style3?=?configFirstCellstyle(workbook);
String?streetSheetName?=?“sheet“;
String[]?sheets?=?new?String[1];
sheets[0]?=?streetSheetName?+?“1“;
for?(int?sheetIndex?=?0;?sheetIndex? //?指定頁腳
HSSFSheet?sheet?=?workbook.createSheet(sheets[sheetIndex]);
sheet.setDefaultColumnWidth(15);
HSSFRow?row?=?sheet.createRow(0);?//?創建第一行
row.setHeight((short)?500);?//?設置行高
HSSFCell?cell?=?row.createCell(0);//?設置第一行
cell.setCellType(HSSFCell.ENCODING_UTF_16);?//?定義單元格為字符串類型
cell.setCellValue(new?HSSFRichTextString(headName));
String[]?keyss?=?keys[0];
int?length?=?keyss.length;
sheet.addMergedRegion(new?CellRangeAddress(0?0?0?length-1));
cell.setCellstyle(style3);
/**
?*?開始生成每一個sheet?先完成標題部分
?*/
String[]?titles?=?headerss[0];
//?產生表格標題行
row?=?sheet.createRow(1);
for?(int?cellIndex?=?0;?cellIndex?tles.length;?cellIndex++)?{
HSSFCell?celltitle?=?row.createCell(cellIndex);
celltitle.setCellstyle(style);
HSSFRichTextString?text?=?new?HSSFRichTextString(
titles[cellIndex]);
celltitle.setCellValue(text);
}
/**
?*?標題制造完畢
?*/
Li

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件????????7770??2017-05-10?16:57??excel導出工具類\ExportExcelUtil.java

評論

共有 條評論