RT
解决方案 »
- 这个图片怎么没调用其呢??求解决。
- 面试题
- 怎么判断一个数是小数?谢谢~
- 一百分相送,加班提问(郁闷中):如何将一个FORM中提交的3个表格分别保存在3个XML文件中,在线等待。。。
- 在C:\Tomcat 4.1\webapps\ROOT下怎么样对SERVLET测试
- Java c/s 服务端如何给客户端返回信息
- 应该怎样学
- 请问这有什么可能情况?
- 关于内部类?
- 我是JAVA的初学者,请各位用什么编程工具好呢,是SDK(我们这找不到有关SDK的盘子)还是VJ++或者JBuilder5?请问高手们java能超过c++吗?
- 请教各位了,今天遇到个问题,在线急等....
- 如何用JAVA将一个给定图象的尺寸扩大或缩小到指定的尺寸!
看看API
可以合并的
* 合并单元格的方法
*
* @param sheet一个HSSFSheet对象
* @param row一个行对象
* @param rowindex行索引 *
* @param name单元格的值 *
* @param a1从第几行开始 *
* @param a2从第几个单元格开始 *
* @param a3到第几行结束
* @param a4到第几个单元格结束 *
*/
public void createCell(int indexRow, int rowindex, String name, int a1,
int a2, int a3, int a4, HSSFCellStyle cellStyle, HSSFFont font,
int flag) {
HSSFRow row = this.sheet.createRow((short) indexRow);
HSSFCell cel0 = row.createCell((short) rowindex);
if (flag == 0) {
cellStyle.setBorderBottom((short) 1);
cellStyle.setBorderLeft((short) 1);
cellStyle.setBorderRight((short) 1);
cellStyle.setBorderTop((short) 1);
cellStyle.setBottomBorderColor((short) 64);
cellStyle.setAlignment((short) 1);
cellStyle.setVerticalAlignment((short) 1);
cellStyle.setDataFormat((short) 49);
}
cel0.setCellStyle(cellStyle);
cel0.setEncoding(HSSFCell.ENCODING_UTF_16);
cel0.setCellValue(name);
sheet.addMergedRegion(new Region(a1, (short) a2, a3, (short) a4));
if (cellStyle != null) {
if (font != null) {
cellStyle.setFont(font);
}
cel0.setCellStyle(cellStyle);
}
}
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet"); HSSFRow row = sheet.createRow((short) 1);
HSSFCell cell = row.createCell((short) 1);
cell.setCellValue("This is a test of merging");
for(int i = 0; i < 10; i++){
sheet.addMergedRegion(new Region(i,(short)1,i,(short)2));
} HSSFSheet sheet1 = wb.createSheet("row sheet");
sheet1.setSelected(true);
// Write the output to a file
try {
FileOutputStream fileOut = new FileOutputStream("workbook.xls");
wb.write(fileOut);
fileOut.close();
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} }