/**
* @author lixiaoqing
*
*/
public class SimpleDemo {
/**
* @param args
*/
public static void main(String[] args) throws Exception{
// TODO Auto-generated method stub
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("new sheet");
// Create a row and put some cells in it. Rows are 0 based.
HSSFRow row = sheet.createRow((short)0);
// Create a cell and put a value in it.
HSSFCell cell = row.createCell((short)0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell((short)1).setCellValue(1.2);
row.createCell((short)2).setCellValue("This is a string");
row.createCell((short)3).setCellValue(true);
// Create a row and put some cells in it. Rows are 0 based.
row = sheet.createRow((short)1);
// Create a cell and put a value in it.
cell = row.createCell((short)0);
cell.setCellValue(1);
// Or do it on one line.
row.createCell((short)1).setCellValue(2.4);
row.createCell((short)2).setCellValue("This is another string");
row.createCell((short)3).setCellValue(false);
// Write the output to a file
FileOutputStream fileOut = new FileOutputStream("workbook2.xls");
wb.write(fileOut);
fileOut.close();
添加区域,合并单元格
Region region = new Region((short)rowFrom,(short)columnFrom,(short)rowTo,(short)columnTo);
sheet.addMergedRegion(region);
//得到所有区域
sheet.getNumMergedRegions()
render_code();