Exemplo n.º 1
0
 public Boolean setHSSFCellValue(int rownum, BinList inlist) {
   Boolean flag = false;
   for (int i = 0; i < inlist.size(); i++) {
     int colnum = Integer.parseInt(inlist.getValue(i, "col").toString());
     String cellvalue = inlist.getValue(i, "value").toString();
     HSSFRow row = this.sheet.getRow(rownum);
     HSSFCell cell = row.getCell((short) colnum);
     if (cell == null) cell = row.createCell((short) colnum);
     cell.setCellType(HSSFCell.CELL_TYPE_STRING);
     cell.setCellValue(cellvalue);
     if (i == inlist.size() - 1) flag = true;
   }
   flag = true;
   return flag;
 }
Exemplo n.º 2
0
  public static void main(String[] args) {
    //		try
    //		{
    //		    POIFSFileSystem fs  =new POIFSFileSystem(new
    // FileInputStream("D:/temp/office/template.xls"));
    //		    HSSFWorkbook wb = new HSSFWorkbook(fs);
    //		    HSSFSheet sheet = wb.getSheetAt(1);
    //		    HSSFRow row = sheet.getRow(8);
    //		    HSSFCell cell = row.getCell((short)0);
    //		    if (cell == null)
    //		        cell = row.createCell((short)0);
    //		    cell.setCellType(HSSFCell.CELL_TYPE_STRING);
    //		    cell.setCellValue("201005");
    //		    // Êä³öÎļþ
    //		    FileOutputStream fileOut = new FileOutputStream("D:/temp/office/test.xls");
    //		    wb.write(fileOut);
    //		    fileOut.close();
    //		}catch(Exception e)
    //		{
    //		    e.printStackTrace();
    //		}

    IExcelImpl excel = new IExcelImpl();
    excel.setFileName("D:/temp/office/template.xls");
    excel.readExecelFile(1);
    BinList inlt = new BinList();
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "0");
    inlt.put(true, "value", "dd");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "2");
    inlt.put(true, "value", "date");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "4");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "5");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "6");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "7");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "8");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "10");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "12");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "13");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "14");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "15");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "16");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "18");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "20");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "22");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "24");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "25");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "26");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "27");
    inlt.put(true, "value", "50");
    inlt.put(false, "row", "8");
    inlt.put(true, "col", "28");
    inlt.put(true, "value", "50");
    excel.setHSSFCellValue(inlt);
    excel.insertRow(8, 1);
    excel.setHSSFCellValue(9, inlt);
    excel.saveExecelFile("D:/temp/office/test2.xls");
  }