日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程语言 > java >内容正文

java

java导出excel 序号_Java 实现导出excel表

發布時間:2023/12/20 java 23 豆豆
生活随笔 收集整理的這篇文章主要介紹了 java导出excel 序号_Java 实现导出excel表 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

/**

* 導出出險信息 fc

*

* @param jzForm

* ? ? ? ? ? ?查詢條件

* @param sessionUser

* ? ? ? ? ? ?當前登錄session用戶

* @param errors

* ? ? ? ? ? ?Action錯誤

* @return

*/

public void exprotAcExcel(List list, String path,HttpServletRequest request) {

try {

WritableWorkbook workbook = Workbook.createWorkbook(new File(path));// 創建工作簿(filePos為excel文件的路徑)

WritableSheet sheet = workbook.createSheet("出險信息", 0);// 創建工作頁

// 內容(居中)單元格樣式

WritableCellFormat contentStyle = new WritableCellFormat(); //

contentStyle.setAlignment(jxl.format.Alignment.CENTRE); // 設置對齊方式

contentStyle.setBorder(jxl.format.Border.ALL,

jxl.format.BorderLineStyle.THIN); // 設置邊框

// 一級標題單元格樣式

WritableFont wf1 = new WritableFont(WritableFont.ARIAL, 15,

WritableFont.BOLD, false); // 定義格式 字體 下劃線 斜體 粗體 顏色

WritableCellFormat titleStyle1 = new WritableCellFormat(wf1); //

titleStyle1.setBackground(jxl.format.Colour.GREEN); // 設置單元格的背景顏色

titleStyle1.setAlignment(jxl.format.Alignment.CENTRE); // 設置對齊方式

titleStyle1.setBorder(jxl.format.Border.ALL,

jxl.format.BorderLineStyle.THIN); // 設置邊框

// 二級標題單元格樣式

WritableFont wf2 = new WritableFont(WritableFont.ARIAL, 11,

WritableFont.BOLD, false); // 定義格式 字體 下劃線 斜體 粗體 顏色

WritableCellFormat titleStyle2 = new WritableCellFormat(wf2); //

titleStyle2.setBackground(jxl.format.Colour.GREY_25_PERCENT); // 設置單元格的背景顏色

titleStyle2.setAlignment(jxl.format.Alignment.CENTRE); // 設置水平對齊方式

titleStyle2

.setVerticalAlignment(jxl.format.VerticalAlignment.CENTRE); // 設置垂直對齊方式

titleStyle2.setBorder(jxl.format.Border.ALL,

jxl.format.BorderLineStyle.THIN); // 設置邊框

WritableCellFormat titleStyle3 = new WritableCellFormat(wf1); //

titleStyle3.setBackground(jxl.format.Colour.BRIGHT_GREEN); // 設置單元格的背景顏色

titleStyle3.setAlignment(jxl.format.Alignment.CENTRE); // 設置對齊方式

titleStyle3.setBorder(jxl.format.Border.ALL,

jxl.format.BorderLineStyle.THIN); // 設置邊框

// 設置凍結單元格

sheet.getSettings().setVerticalFreeze(2);

sheet.getSettings().setHorizontalFreeze(5);

sheet.setColumnView(0, 8); // 設置列的寬度

sheet.setColumnView(1, 10); // 設置列的寬度

sheet.setRowView(0, 0);

sheet.addCell(new Label(0, 0, "hysj5800294*#", titleStyle1));// 標題

sheet.addCell(new Label(0, 1, "出險信息 ", titleStyle2));// 標題

sheet.mergeCells(0, 2, 33, 2); // 合并單元格

sheet.addCell(new Label(0, 2, "出險信息 ", titleStyle1));// 標題

sheet.addCell(new Label(0, 3, "序號", titleStyle2));// 往單元格中填寫數據

sheet.addCell(new Label(1, 3, "省內/省外", titleStyle2));// 往單元格中填寫數據

if (list != null && list.size() > 0) {

for (int i = 0; i < list.size(); i++) {

sheet.setRowView(i + 3, 300); // 設置行高

//轉換數據信息

//Object[] obj = (Object[]) list.get(i);

AccidentRecord ar = (AccidentRecord) list.get(i);

sheet.addCell(new Label(0, i + 4, String.valueOf(i + 1),contentStyle));// 往單元格中填寫數據 序號

sheet.addCell(new Label(1, i + 4, ar.getLicenceProvince().toString(),contentStyle));// ?省內/省外

}

}

workbook.write();// 書寫到工作簿

workbook.close();// 關閉工作簿,輸出完成

} catch (Exception e) {

e.printStackTrace();

}

}

}

總結

以上是生活随笔為你收集整理的java导出excel 序号_Java 实现导出excel表的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。