下载jxl。。 或者poi也可以。
http://www.andykhan.com/jexcelapi/
//生成报表
private void PrintExcal(String result) {
try {
WritableWorkbook workbook = Workbook.createWorkbook(new File(result));
WritableSheet sheet = workbook.createSheet("First Sheet", 0);
// 定义18号字体
WritableFont arial18font = new WritableFont(WritableFont.ARIAL, 18);
WritableCellFormat arial18format = new WritableCellFormat(arial18font);
//定义14号字体
WritableFont arial14font = new WritableFont(WritableFont.ARIAL, 14);
WritableCellFormat arial14format = new WritableCellFormat(arial14font);
jxl.write.Label label = new jxl.write.Label(0, 1, "DCN设备使用情况月表",
arial18format);
try {
sheet.addCell(label);
label = new jxl.write.Label(0, 3,
MonthInputYear.getText() + "年" +
MonthInputMonth.getText() + "月",
arial14format);
sheet.addCell(label);
label = new jxl.write.Label(4, 3, "填表单位:" + EUSPDepName.getText(),
arial14format);
sheet.addCell(label);