POI操作EXCEL技巧Word格式.docx

上传人:b****4 文档编号:6915584 上传时间:2023-05-07 格式:DOCX 页数:46 大小:30.42KB
下载 相关 举报
POI操作EXCEL技巧Word格式.docx_第1页
第1页 / 共46页
POI操作EXCEL技巧Word格式.docx_第2页
第2页 / 共46页
POI操作EXCEL技巧Word格式.docx_第3页
第3页 / 共46页
POI操作EXCEL技巧Word格式.docx_第4页
第4页 / 共46页
POI操作EXCEL技巧Word格式.docx_第5页
第5页 / 共46页
POI操作EXCEL技巧Word格式.docx_第6页
第6页 / 共46页
POI操作EXCEL技巧Word格式.docx_第7页
第7页 / 共46页
POI操作EXCEL技巧Word格式.docx_第8页
第8页 / 共46页
POI操作EXCEL技巧Word格式.docx_第9页
第9页 / 共46页
POI操作EXCEL技巧Word格式.docx_第10页
第10页 / 共46页
POI操作EXCEL技巧Word格式.docx_第11页
第11页 / 共46页
POI操作EXCEL技巧Word格式.docx_第12页
第12页 / 共46页
POI操作EXCEL技巧Word格式.docx_第13页
第13页 / 共46页
POI操作EXCEL技巧Word格式.docx_第14页
第14页 / 共46页
POI操作EXCEL技巧Word格式.docx_第15页
第15页 / 共46页
POI操作EXCEL技巧Word格式.docx_第16页
第16页 / 共46页
POI操作EXCEL技巧Word格式.docx_第17页
第17页 / 共46页
POI操作EXCEL技巧Word格式.docx_第18页
第18页 / 共46页
POI操作EXCEL技巧Word格式.docx_第19页
第19页 / 共46页
POI操作EXCEL技巧Word格式.docx_第20页
第20页 / 共46页
亲,该文档总共46页,到这儿已超出免费预览范围,如果喜欢就下载吧!
下载资源
资源描述

POI操作EXCEL技巧Word格式.docx

《POI操作EXCEL技巧Word格式.docx》由会员分享,可在线阅读,更多相关《POI操作EXCEL技巧Word格式.docx(46页珍藏版)》请在冰点文库上搜索。

POI操作EXCEL技巧Word格式.docx

28. 

29. 

sheet 

30. 

31. 

// 

Create 

row 

and 

put 

some 

cells 

in 

it. 

Rows 

are 

based. 

32. 

33. 

HSSFRow 

sheet.createRow((short)0);

34. 

35. 

cell 

value 

36. 

37. 

HSSFCell 

row.createCell((short)0);

38. 

39. 

cell.setCellValue

(1);

40. 

41. 

Or 

do 

it 

on 

one 

line. 

42. 

43. 

row.createCell((short)1).setCellValue(1.2);

44. 

45. 

row.createCell((short)2).setCellValue("

This 

is 

string"

46. 

47. 

row.createCell((short)3).setCellValue(true);

48. 

49. 

Write 

the 

output 

to 

file 

50. 

51. 

52. 

53. 

54. 

55. 

56. 

57.4.创建指定单元格式的单元格 

58. 

59. 

60. 

61. 

62. 

63. 

64. 

65. 

66. 

67. 

date 

The 

first 

not 

styled 

68. 

69. 

as 

date. 

70. 

71. 

72. 

73. 

cell.setCellValue(new 

Date());

74. 

75. 

we 

style 

(and 

time). 

It 

important 

76. 

77. 

create 

from 

workbook 

otherwise 

you 

can 

end 

up 

78. 

79. 

modifying 

built 

effecting 

only 

this 

but 

other 

cells. 

80. 

81. 

HSSFCellStyle 

cellStyle 

wb.createCellStyle();

82. 

83. 

cellStyle.setDataFormat(HSSFDataFormat.getBuiltinFormat("

m/d/yy 

h:

mm"

));

84. 

85. 

row.createCell((short)1);

86. 

87. 

88. 

89. 

cell.setCellStyle(cellStyle);

90. 

91. 

92. 

93. 

94. 

95. 

96. 

97. 

98. 

99.5. 

单元格的不同格式 

100. 

101. 

102. 

103. 

104. 

105. 

sheet.createRow((short)2);

106. 

107. 

row.createCell((short) 

0).setCellValue(1.1);

108. 

109. 

1).setCellValue(new 

110. 

111. 

2).setCellValue("

112. 

113. 

3).setCellValue(true);

114. 

115. 

4).setCellType(HSSFCell.CELL_TYPE_ERROR);

116. 

117. 

118. 

119. 

120. 

121. 

122. 

123. 

124. 

125.6.单元格的不通对齐方式 

126. 

127. 

public 

static 

void 

main(String[] 

args) 

128. 

129. 

throws 

IOException 

130. 

131. 

132. 

133. 

134. 

135. 

136. 

137. 

sheet.createRow((short) 

2);

138. 

139. 

createCell(wb, 

row, 

(short) 

0, 

HSSFCellStyle.ALIGN_CENTER);

140. 

141. 

1, 

HSSFCellStyle.ALIGN_CENTER_SELECTION);

142. 

143. 

2, 

HSSFCellStyle.ALIGN_FILL);

144. 

145. 

3, 

HSSFCellStyle.ALIGN_GENERAL);

146. 

147. 

4, 

HSSFCellStyle.ALIGN_JUSTIFY);

148. 

149. 

5, 

HSSFCellStyle.ALIGN_LEFT);

150. 

151. 

6, 

HSSFCellStyle.ALIGN_RIGHT);

152. 

153. 

154. 

155. 

156. 

157. 

158. 

159. 

160. 

161. 

162. 

163. 

/** 

164. 

165. 

Creates 

aligns 

certain 

way. 

166. 

167. 

168. 

169. 

@param 

170. 

171. 

172. 

173. 

column 

number 

174. 

175. 

align 

alignment 

for 

cell. 

176. 

177. 

*/ 

178. 

179. 

private 

createCell(HSSFWorkbook 

wb, 

short 

column, 

align) 

180. 

181. 

182. 

183. 

row.createCell(column);

184. 

185. 

cell.setCellValue("

Align 

It"

186. 

187. 

188. 

189. 

cellStyle.setAlignment(align);

190. 

191. 

192. 

193. 

194. 

195.7.单元格的边框设置 

196. 

197.Working 

with 

borders 

198. 

199. 

200. 

201. 

202. 

203. 

204. 

205. 

1);

206. 

207. 

208. 

209. 

210. 

211. 

cell.setCellValue(4);

212. 

213. 

Style 

all 

around. 

214. 

215. 

216. 

217. 

style.setBorderBottom(HSSFCellStyle.BORDER_THIN);

218. 

219. 

style.setBottomBorderColor(HSSFColor.BLACK.index);

220. 

221. 

style.setBorderLeft(HSSFCellStyle.BORDER_THIN);

222. 

223. 

style.setLeftBorderColor(HSSFColor.GREEN.index);

224. 

225. 

style.setBorderRight(HSSFCellStyle.BORDER_THIN);

226. 

227. 

style.setRightBorderColor(HSSFColor.BLUE.index);

228. 

229. 

style.setBorderTop(HSSFCellStyle.BORDER_MEDIUM_DASHED);

230. 

231. 

style.setTopBorderColor(HSSFColor.BLACK.index);

232. 

233. 

cell.setCellStyle(style);

234. 

235. 

236. 

237. 

238. 

239. 

240. 

241. 

242. 

243.8.填充和颜色设置 

244. 

245. 

246. 

247. 

248. 

249. 

250. 

251. 

252. 

253. 

Aqua 

background 

254. 

255. 

256. 

257. 

style.setFillBackgroundColor(HSSFColor.AQUA.index);

258. 

259. 

style.setFillPattern(HSSFCellStyle.BIG_SPOTS);

260. 

261. 

262. 

263. 

X"

264. 

265. 

266. 

267. 

Orange 

"

foreground"

 

foreground 

being 

fill 

font 

color. 

268. 

269. 

270. 

271. 

style.setFillForegroundColor(HSSFColor.ORANGE.index);

272. 

273. 

style.setFillPattern(HSSFCellStyle.SOLID_FOREGROUND);

274. 

275. 

276. 

277. 

278. 

279. 

280. 

281. 

282. 

283. 

284. 

285. 

286. 

287. 

288. 

289.9.合并单元格操作 

290. 

291. 

292. 

293. 

294. 

295. 

296. 

297. 

298. 

299. 

test 

of 

merging"

300. 

301. 

sheet

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > PPT模板 > 商务科技

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2