可以试试JavaCellREport.  http://www.javatoolsoft.com/cn

解决方案 »

  1.   


    import org.apache.poi.hssf.usermodel.*;
    import org.apache.poi.hssf.util.HSSFColor;
    import org.apache.poi.hssf.util.Region;
    import org.apache.poi.poifs.filesystem.POIFSFileSystem;import java.io.FileInputStream;
    import java.io.FileOutputStream;
    import java.util.*;
    /**
     * <p>Title: </p>
     * <p>Description: </p>
     * <p>Copyright: Copyright (c) 2004</p>
     * <p>Company: </p>
     * @author not attributable
     * @version 1.0
     */public class TestExcelPrint {  public String printExcel(List xmlList,Object doc) throws Exception{
        String strName = "";    return strName;
      }
      static public void main(String[] args) throws Exception {    FileInputStream fos = new FileInputStream("jixing.xls");
        POIFSFileSystem fs = new POIFSFileSystem(fos);    HSSFWorkbook wb = new HSSFWorkbook(fs);    HSSFSheet sheet = wb.getSheetAt(0);    HSSFRow row;
        HSSFCell cell;    HSSFCellStyle style = wb.createCellStyle();
        style = wb.createCellStyle();
        style.setBorderBottom(HSSFCellStyle.BORDER_THIN);
        style.setBottomBorderColor(HSSFColor.BLACK.index);
        style.setBorderLeft(HSSFCellStyle.BORDER_THIN);
        style.setLeftBorderColor(HSSFColor.BLACK.index);
        style.setBorderRight(HSSFCellStyle.BORDER_THIN);
        style.setRightBorderColor(HSSFColor.BLACK.index);
        style.setBorderTop(HSSFCellStyle.BORDER_THIN);
        style.setTopBorderColor(HSSFColor.BLACK.index);
        style.setAlignment(HSSFCellStyle.ALIGN_CENTER);
        style.setVerticalAlignment(HSSFCellStyle.VERTICAL_CENTER);
        style.setWrapText(true);    row = sheet.getRow(3);
        cell = row.getCell((short)1);
        if (cell == null)
            cell = row.createCell((short)1);
        cell.setEncoding(HSSFCell.ENCODING_UTF_16);
        cell.setCellValue("1111111111");    String getFieldName1 = "";
        List list= null;
        if (list != null) {
          Iterator aa = list.iterator();
          for(;aa.hasNext();){
            Object doc = (Object)aa.next();      }
        }    for (short i = 7; i < 15; i++) {      row = sheet.createRow(i);      for (short j = 0; j < 10; j++) {
            cell = row.createCell(j);
            if (i == 8){
              sheet.addMergedRegion(new Region(8,(short) 1,9,(short) 1));
            }        cell.setCellType(HSSFCell.CELL_TYPE_STRING);
            cell.setEncoding(HSSFCell.ENCODING_UTF_16);
            cell.setCellStyle(style);
            cell.setCellValue("" + i + "," + j);      }  }
      FileOutputStream fileOut = new FileOutputStream("jijingout.xls");
      wb.write(fileOut);  fos.close();  }
    }
    我已经用那个控件做了个例子,现在问题是想把这个方法做成一个公共的,每个不同的统计列表都用这个方法,可就是不知道怎么设计合理,帮忙出出主意吧,兄弟们
      

  2.   

    利用XML描述你的报表咯 我最近也在做这方面的任务
    觉得挺有意思的 都是可以自己定义的嘛XML
      

  3.   

    请问shuneng() 你是怎样利用XML描述的?能给个例子看看吗?