Vincent
BlogJava
::
首頁
::
新隨筆
::
聯系
::
聚合
::
管理
posts - 5, comments - 7, trackbacks - 0
<
2025年7月
>
日
一
二
三
四
五
六
29
30
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
31
1
2
3
4
5
6
7
8
9
常用鏈接
我的隨筆
我的評論
我的參與
最新評論
留言簿
(2)
給我留言
查看公開留言
查看私人留言
隨筆分類
snmp(4)
隨筆檔案
2009年6月 (5)
文章分類
JavaScript(8)
JDBC(1)
JfreeChart(1)
JSF(13)
JXL(2)
POI(9)
Print(8)
richfaces(4)
SQL(1)
Swing
tomcat
XML(5)
文章檔案
2008年12月 (2)
2008年11月 (42)
jsf
JSF中文技術文摘
JSF中文技術文摘
JSF中文技術文摘
Webservice技術學習專題
搜索
積分與排名
積分 - 56066
排名 - 925
最新評論
1.?re: POI實現Excel插入圖片[未登錄]
能不能在頁腳或者頁眉插入圖片呢
--lsy
2.?re: C# Sample code to talk to a printer using SNMP to get its status.
評論內容較長,點擊標題查看
--KCC
3.?re: C# Sample code to talk to a printer using SNMP to get its status.
評論內容較長,點擊標題查看
--phaneendra
4.?re: java報表JXL和POI打印設置[未登錄]
aaaaaaaaaaaaaa
--aaa
5.?re: POI實現Excel插入圖片
非常好 ! 謝謝!
--estc
閱讀排行榜
1.?C# Sample code to talk to a printer using SNMP to get its status. (6588)
2.?Cisco常用OID(2899)
3.?OID(1537)
4.?Communicating with SNMP using C# - The Very Beginning (1530)
5.?OID(715)
評論排行榜
1.?C# Sample code to talk to a printer using SNMP to get its status. (2)
2.?Communicating with SNMP using C# - The Very Beginning (1)
3.?OID(0)
4.?OID(0)
5.?Cisco常用OID(0)
使用POI生成Excel文檔并設置打印樣式
1
package
test;
2
3
import
java.io.FileOutputStream;
4
import
java.io.IOException;
5
6
import
org.apache.poi.hssf.usermodel.HSSFCell;
7
import
org.apache.poi.hssf.usermodel.HSSFCellStyle;
8
import
org.apache.poi.hssf.usermodel.HSSFFont;
9
import
org.apache.poi.hssf.usermodel.HSSFPrintSetup;
10
import
org.apache.poi.hssf.usermodel.HSSFRichTextString;
11
import
org.apache.poi.hssf.usermodel.HSSFRow;
12
import
org.apache.poi.hssf.usermodel.HSSFSheet;
13
import
org.apache.poi.hssf.usermodel.HSSFWorkbook;
14
15
public
class
ExcelTest
{
16
17
public
static
void
main(String[] args)
throws
IOException
{
18
19
//
create a new file
20
FileOutputStream out
=
new
FileOutputStream(
"
D:/workbook.xls
"
);
21
//
create a new workbook
22
HSSFWorkbook wb
=
new
HSSFWorkbook();
23
//
create a new sheet
24
HSSFSheet sheet
=
wb.createSheet();
25
26
//
2.model
27
HSSFRow row
=
sheet.createRow(
2
);
28
row.setHeightInPoints(
20
);
29
HSSFCell cell
=
row.createCell(
2
);
30
HSSFFont cnFont
=
wb.createFont();
31
cnFont.setFontHeightInPoints((
short
)
10
);
32
//
font.setFontName("漢儀報宋簡");
33
cnFont.setFontName(
"
隸書
"
);
34
HSSFCellStyle cnStyle
=
wb.createCellStyle();
35
cnStyle.setFont(cnFont);
36
cell.setCellStyle(cnStyle);
37
HSSFRichTextString richText
=
new
HSSFRichTextString(
"
中文字體測試
"
);
38
cell.setCellValue(richText);
39
HSSFCell enCell
=
row.createCell(
3
);
40
HSSFFont enFont
=
wb.createFont();
41
enFont.setFontHeightInPoints((
short
)
10
);
42
enFont.setFontName(
"
Arial Black
"
);
43
HSSFCellStyle enStyle
=
wb.createCellStyle();
44
enStyle.setFont(enFont);
45
enCell.setCellStyle(enStyle);
46
enCell.setCellValue(
new
HSSFRichTextString(
"
English font test
"
));
47
sheet.setColumnWidth(
2
,
4000
);
48
sheet.setColumnWidth(
3
,
4000
);
49
50
//
3.output
51
sheet.setDisplayGridlines(
false
);
52
sheet.setPrintGridlines(
false
);
53
HSSFPrintSetup printSetup
=
sheet.getPrintSetup();
54
//
A4紙
55
printSetup.setPaperSize(HSSFPrintSetup.A4_PAPERSIZE);
56
wb.write(out);
57
out.close();
58
}
59
}
60
posted on 2008-11-25 11:47
Vincent-chen
閱讀(2198)
評論(0)
編輯
收藏
所屬分類:
POI
、
Print
新用戶注冊
刷新評論列表
只有注冊用戶
登錄
后才能發表評論。
網站導航:
博客園
IT新聞
Chat2DB
C++博客
博問
管理
相關文章:
操作word的解決方案
POI 將數據導出到Word的實例
使用POI來處理Excel和Word文件格式
使用poi生成excel文件
一步一步使用POI做java報表
一步一步使用POI做java報表--打印設置篇
使用POI生成Excel文檔并設置打印樣式
使用POI向Excel里插入圖片
POI實現Excel插入圖片
Powered by:
BlogJava
Copyright ©2025 Vincent-chen
主站蜘蛛池模板:
和顺县
|
宜丰县
|
正阳县
|
高密市
|
英德市
|
张北县
|
增城市
|
苍溪县
|
和林格尔县
|
宾阳县
|
和田县
|
长子县
|
东山县
|
息烽县
|
皋兰县
|
永宁县
|
通榆县
|
博客
|
本溪
|
新晃
|
秦安县
|
黄平县
|
上思县
|
成武县
|
平乡县
|
印江
|
仁寿县
|
平湖市
|
黄陵县
|
郴州市
|
平山县
|
稻城县
|
广平县
|
大悟县
|
页游
|
达州市
|
东台市
|
将乐县
|
苍溪县
|
大方县
|
年辖:市辖区
|