Rising Sun
BlogJava
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
::
148 隨筆 :: 0 文章 :: 22 評論 :: 0 Trackbacks
<
2006年9月
>
日
一
二
三
四
五
六
27
28
29
30
31
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
1
2
3
4
5
6
7
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(10)
給我留言
查看公開留言
查看私人留言
隨筆分類
cpp(3)
(rss)
css(6)
(rss)
hibernate+struts+spring(3)
(rss)
javascript(9)
(rss)
Lucene(3)
(rss)
oracle 數據庫(6)
(rss)
云計算(4)
(rss)
其它(6)
(rss)
處理Excel poi(6)
(rss)
學習總結(15)
(rss)
環境設置(2)
(rss)
隨筆檔案
2015年1月 (3)
2014年12月 (1)
2014年9月 (1)
2014年6月 (2)
2014年4月 (2)
2014年1月 (2)
2013年12月 (3)
2013年11月 (1)
2013年10月 (2)
2013年8月 (2)
2013年7月 (3)
2013年5月 (3)
2013年3月 (9)
2013年2月 (8)
2013年1月 (4)
2012年10月 (1)
2012年9月 (2)
2012年8月 (1)
2012年7月 (3)
2012年5月 (1)
2012年1月 (1)
2011年3月 (1)
2010年12月 (1)
2009年12月 (1)
2009年10月 (1)
2009年8月 (4)
2009年7月 (3)
2009年6月 (2)
2009年5月 (2)
2009年4月 (3)
2008年11月 (3)
2008年10月 (2)
2008年9月 (1)
2008年8月 (2)
2008年7月 (3)
2008年5月 (1)
2007年11月 (1)
2007年10月 (2)
2007年9月 (2)
2007年8月 (3)
2007年7月 (6)
2007年6月 (3)
2007年4月 (2)
2006年12月 (2)
2006年11月 (1)
2006年10月 (2)
2006年9月 (3)
2006年8月 (3)
2006年7月 (26)
2005年11月 (4)
相冊
我的相冊
java--->ajax
BlueDavy
http://www.aygfsteel.com/BlueDavy/
css
css
eamoi
搜索
最新評論
1.?re: request.getParameterValues與request.getParameter的區別:
5+5+
--5465
2.?re: 關于filter驗證用戶權限
333
--12
3.?re: Gson通過借助TypeToken獲取泛型參數的類型的方法
博主如果解決了樓上的問題 請聯系我 萬分感謝 聯系方式QQ 474233979
--yueguangxuanyuan
4.?re: Gson通過借助TypeToken獲取泛型參數的類型的方法
評論內容較長,點擊標題查看
--yueguangxuanyuan
5.?re: CMS,全稱Concurrent Low Pause Collector gc[未登錄]
很有用。非常感謝!!!!
--匿名
閱讀排行榜
1.?Gson通過借助TypeToken獲取泛型參數的類型的方法(42682)
2.?304 Not Modified狀態碼(18909)
3.?電腦非法關機 導致ORA-01033:解決方法(9095)
4.?struts2 -- interceptor(如何配置Interceptor) (7517)
5.?MYSQL在默認的情況下查詢是不區分大小寫的(7361)
評論排行榜
1.?Gson通過借助TypeToken獲取泛型參數的類型的方法(6)
2.?Busy Developers' Guide to HSSF Features (說明書)(3)
3.?對于網上看到Window.Open()傳值(3)
4.?excel 處理 Poi(1)
5.?關于filter驗證用戶權限(1)
excel poi 處理2
在導出數據生成excel時,定義excel單元格格式為文本。
最好拿你的導出代碼貼出來看看,主要是生成excel時代碼
--------------------------------------------------------------------------------
參考一下.
<%
@?page?contentType
=
"
text/html;?charset=gb2312
"
%>
<%
@?page?
import
=
"
java.io.*
"
%>
<%
@?page?
import
=
"
org.apache.poi.hssf.util.HSSFColor
"
%>
<%
@?page?
import
=
"
org.apache.poi.hssf.util.Region
"
%>
<%
@?page?
import
=
"
org.apache.poi.hssf.usermodel.*
"
%>
<%
//
初始化
//
工作簿
HSSFWorkbook?wb
=
new
?HSSFWorkbook();
//
工作表
HSSFSheet?sheet
=
wb.createSheet();
wb.setSheetName(
0
,
"
Excel演示!
"
,HSSFWorkbook.ENCODING_UTF_16);
//
準備完成
//
建樣式
//
標題字
HSSFFont?font_Header
=
wb.createFont();
font_Header.setFontName(
"
headerFont
"
);
font_Header.setFontHeightInPoints((
short
)
12
);
HSSFCellStyle?cellStyle_Header
=
wb.createCellStyle();
cellStyle_Header.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyle_Header.setFont(font_Header);
//
通用行
HSSFCellStyle?cellStyle_Normal
=
wb.createCellStyle();
cellStyle_Normal.setAlignment(HSSFCellStyle.ALIGN_LEFT);
//
cellStyle_Normal.setBorderBottom(HSSFCellStyle.BORDER_THIN);
//
cellStyle_Normal.setBorderLeft(HSSFCellStyle.BORDER_THIN);
//
cellStyle_Normal.setBorderRight(HSSFCellStyle.BORDER_THIN);
//
cellStyle_Normal.setBorderTop(HSSFCellStyle.BORDER_THIN);
//
表格頭
HSSFCellStyle?cellStyle_Column
=
wb.createCellStyle();
cellStyle_Column.setAlignment(HSSFCellStyle.ALIGN_CENTER);
cellStyle_Column.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
cellStyle_Column.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle_Column.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle_Column.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle_Column.setBorderTop(HSSFCellStyle.BORDER_THIN);
cellStyle_Column.setFillPattern(HSSFCellStyle.BIG_SPOTS);
cellStyle_Column.setFillBackgroundColor((
short
)HSSFColor.WHITE.index);
cellStyle_Column.setFillForegroundColor(HSSFColor.GREY_25_PERCENT.index);
//
數據行
HSSFCellStyle?cellStyle_Cell
=
wb.createCellStyle();
cellStyle_Cell.setAlignment(HSSFCellStyle.ALIGN_LEFT);
cellStyle_Cell.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
cellStyle_Cell.setBorderBottom(HSSFCellStyle.BORDER_THIN);
cellStyle_Cell.setBorderLeft(HSSFCellStyle.BORDER_THIN);
cellStyle_Cell.setBorderRight(HSSFCellStyle.BORDER_THIN);
cellStyle_Cell.setBorderTop(HSSFCellStyle.BORDER_THIN);
cellStyle_Cell.setWrapText(
true
);
//
樣式結束
//
置標題
HSSFRow?row
=
sheet.createRow((
short
)
0
);
HSSFCell?cell
=
row.createCell((
short
)
0
);
cell.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
cell.setCellValue(
"
Excel演示!
"
);
sheet.addMergedRegion(
new
?Region(
0
,(
short
)
0
,
0
,(
short
)
5
));
cell.setCellStyle(cellStyle_Header);
//
完成標題
//
行信息
row
=
sheet.createRow((
short
)
1
);
cell
=
row.createCell((
short
)
0
);
cell.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
cell.setCellValue(
"
FieldName
"
);
cell.setCellStyle(cellStyle_Normal);
cell
=
row.createCell((
short
)
1
);
cell.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
cell.setCellValue(
"
FieldValue
"
);
sheet.addMergedRegion(
new
?Region(
1
,(
short
)
1
,
1
,(
short
)
2
));
cell.setCellStyle(cellStyle_Normal);
cell
=
row.createCell((
short
)
3
);
cell.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
cell.setCellValue(
"
FieldName
"
);
cell.setCellStyle(cellStyle_Normal);
cell
=
row.createCell((
short
)
4
);
cell.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
cell.setCellValue(
"
FieldValue
"
);
sheet.addMergedRegion(
new
?Region(
1
,(
short
)
4
,
1
,(
short
)
5
));
cell.setCellStyle(cellStyle_Normal);
//
表數據
for
(
int
?mIndex
=
2
;mIndex
<
10
;mIndex
++
)
{
row
=
sheet.createRow((
short
)mIndex);
for
(
int
?nIndex
=
0
;nIndex
<
6
;nIndex
++
)
{
cell
=
row.createCell((
short
)nIndex);
cell.setEncoding(HSSFWorkbook.ENCODING_UTF_16);
cell.setCellValue(
"
00.00
"
);
cell.setCellStyle(cellStyle_Cell);
}
}
//
全局調
sheet.setHorizontallyCenter(
true
);
for
(
int
?kIndex
=
0
;kIndex
<
10
;kIndex
++
)
{
sheet.setColumnWidth((
short
)kIndex,(
short
)
4500
);
}
sheet.setMargin(HSSFSheet.BottomMargin,(
double
)
0.5
);
sheet.setMargin(HSSFSheet.LeftMargin,(
double
)
0.1
);
sheet.setMargin(HSSFSheet.RightMargin,(
double
)
0.1
);
sheet.setMargin(HSSFSheet.TopMargin,(
double
)
0.5
);
//
調整結束
//
輸出Excel
OutputStream?outData
=
null
;
outData
=
response.getOutputStream();
response.setContentType(
"
application/vnd.ms-excel
"
);
wb.write(outData);
outData.flush();
response.flushBuffer();
//
完成
%>
posted on 2006-09-19 15:59
brock
閱讀(403)
評論(0)
編輯
收藏
所屬分類:
處理Excel poi
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
excel poi 處理2
Busy Developers' Guide to HSSF Features (說明書)
excel 處理 Poi
利用POI將數據表導入Excel
純java的Excel解決方案
Excel的java處理方式
Powered by:
BlogJava
Copyright © brock
主站蜘蛛池模板:
盐亭县
|
瑞安市
|
边坝县
|
南丰县
|
宁化县
|
达日县
|
兴化市
|
西林县
|
民丰县
|
台湾省
|
中阳县
|
五原县
|
虎林市
|
阿拉善右旗
|
平舆县
|
仪陇县
|
永州市
|
永春县
|
和龙市
|
龙井市
|
鄂托克前旗
|
玉环县
|
乌苏市
|
锦屏县
|
新泰市
|
甘泉县
|
平和县
|
南华县
|
松阳县
|
永靖县
|
克东县
|
黄冈市
|
营口市
|
宁海县
|
民权县
|
大英县
|
丹棱县
|
德庆县
|
佛坪县
|
红河县
|
钟山县
|