Java jsp excel 在jsp中写一个表格,然后我想把这个表格下载到本地.就是单击按钮提示是否保存..求详解.. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 这个应该去JAVA 版。JXL 可以帮你。设计文件的导出。需要编程实现 /* // 设置单元格表头 response.reset(); response.setContentType("application/msxls"); response.setHeader("Content-Disposition", "attachment; filename=" + new String("出纳付款.xls".getBytes("GBK"), "ISO8859-1")); response.setHeader("Cache-Control", "no-cache"); // 设置列文字格式 WritableFont fontTitle = new WritableFont( WritableFont.createFont("宋体"), 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE); WritableCellFormat formatTitle = new WritableCellFormat(fontTitle); formatTitle.setAlignment(jxl.format.Alignment.CENTRE); formatTitle.setBorder(Border.ALL, BorderLineStyle.THIN); formatTitle.setBackground(Colour.LIGHT_GREEN); // 设置单元格文字格式 WritableFont fontBody = new WritableFont(WritableFont.createFont("宋体"), 10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE); WritableCellFormat formatBody = new WritableCellFormat(fontBody); formatBody.setBorder(Border.ALL, BorderLineStyle.THIN); formatBody.setAlignment(jxl.format.Alignment.CENTRE); NumberFormat nf = new NumberFormat("0.00"); WritableCellFormat wcfN = new WritableCellFormat(fontBody, nf); wcfN.setBorder(Border.ALL, BorderLineStyle.THIN); wcfN.setAlignment(jxl.format.Alignment.CENTRE); List<Object[]> list = new ArrayList<Object[]>(); list = brPlanBalanceReconcService.getPayList(companyId); WritableWorkbook book = null; try { book = Workbook.createWorkbook(response.getOutputStream()); // 设置excel第一列 WritableSheet sheet = book.createSheet("出纳付款", 0); Label label = new Label(0, 0, "序号", formatTitle); sheet.addCell(label); label = new Label(1, 0, "公司/部门", formatTitle); sheet.addCell(label); label = new Label(2, 0, "凭证编号", formatTitle); sheet.addCell(label); label = new Label(3, 0, "出/收款行", formatTitle); sheet.addCell(label); label = new Label(4, 0, "出/收款账户", formatTitle); sheet.addCell(label); label = new Label(5, 0, "对方开户行", formatTitle); sheet.addCell(label); label = new Label(6, 0, "对方账户", formatTitle); sheet.addCell(label); label = new Label(7, 0, "金额", formatTitle); sheet.addCell(label); label = new Label(8, 0, "年月", formatTitle); sheet.addCell(label); // 设置单元格宽度 sheet.setColumnView(0, 10); sheet.setColumnView(1, 15); sheet.setColumnView(2, 20); sheet.setColumnView(3, 20); sheet.setColumnView(4, 20); sheet.setColumnView(5, 20); sheet.setColumnView(6, 20); sheet.setColumnView(7, 15); sheet.setColumnView(8, 15); if (list != null && list.size() > 0) { for (int i = 0; i < list.size(); i++) { Object[] temp = (Object[]) list.get(i); label = new Label(0, i + 1, i + 1 + "", formatBody);// 文件序号 sheet.addCell(label); if (temp[0] == null) { temp[0] = ""; } label = new Label(1, i + 1, temp[0] + "", formatBody);// 公司/部门 sheet.addCell(label); if (temp[1] == null) { temp[1] = ""; } label = new Label(2, i + 1, temp[1] + "", formatBody);// 凭证编号 sheet.addCell(label); if (temp[2] == null) { temp[2] = ""; } label = new Label(3, i + 1, temp[2] + "", formatBody);// 出/收款行 sheet.addCell(label); if (temp[3] == null) { temp[3] = ""; } label = new Label(4, i + 1, temp[3] + "", formatBody);// 出/收款账户 sheet.addCell(label); if (temp[4] == null) { temp[4] = ""; } label = new Label(5, i + 1, temp[4] + "", formatBody);// 对方开户行 sheet.addCell(label); if (temp[5] == null) { temp[5] = ""; } label = new Label(6, i + 1, temp[5] + "", formatBody);// 对方账户 sheet.addCell(label); if (temp[6] == null) { temp[6] = ""; } label = new Label(7, i + 1, temp[6] + "", formatBody);// 金额 sheet.addCell(label); if (temp[7] == null) { temp[7] = ""; } label = new Label(8, i + 1, temp[7] + "", formatBody);// 月份 sheet.addCell(label); } } } catch (Exception e) { e.printStackTrace(); } finally { // 写出并关闭流 if (book != null) { try { book.write(); book.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (WriteException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }*/贴个例子给你,研究研究 oracle oracle数据导出问题 大数据量快速插入 北京外企高薪聘有ERP经验的Oracle开发人员 求一SQL语句 能不能在一条SQL语句对一个表进行修改?例如进行修改一个字段名并删除几个字段名和增加几个字段。 如何把这个SQL语句转化为ORACLE的合法语句--解决了就给分 oracle 中blog字段,无法读出的原因???高手帮忙...... 向oracle中插入数据时,要先判断是否有,有则更新,没有插入,可不可以直接插入? 请教:从游标中读取记录的问题!! netca 无法运行 在Oracle 中创建存储过程时,要传递参数时要用数组,请问该怎么弄呢?
// 设置单元格表头
response.reset();
response.setContentType("application/msxls");
response.setHeader("Content-Disposition", "attachment; filename="
+ new String("出纳付款.xls".getBytes("GBK"), "ISO8859-1"));
response.setHeader("Cache-Control", "no-cache");
// 设置列文字格式
WritableFont fontTitle = new WritableFont(
WritableFont.createFont("宋体"), 10, WritableFont.NO_BOLD, false,
UnderlineStyle.NO_UNDERLINE);
WritableCellFormat formatTitle = new WritableCellFormat(fontTitle);
formatTitle.setAlignment(jxl.format.Alignment.CENTRE);
formatTitle.setBorder(Border.ALL, BorderLineStyle.THIN);
formatTitle.setBackground(Colour.LIGHT_GREEN); // 设置单元格文字格式
WritableFont fontBody = new WritableFont(WritableFont.createFont("宋体"),
10, WritableFont.NO_BOLD, false, UnderlineStyle.NO_UNDERLINE);
WritableCellFormat formatBody = new WritableCellFormat(fontBody);
formatBody.setBorder(Border.ALL, BorderLineStyle.THIN);
formatBody.setAlignment(jxl.format.Alignment.CENTRE);
NumberFormat nf = new NumberFormat("0.00");
WritableCellFormat wcfN = new WritableCellFormat(fontBody, nf);
wcfN.setBorder(Border.ALL, BorderLineStyle.THIN);
wcfN.setAlignment(jxl.format.Alignment.CENTRE); List<Object[]> list = new ArrayList<Object[]>();
list = brPlanBalanceReconcService.getPayList(companyId); WritableWorkbook book = null;
try {
book = Workbook.createWorkbook(response.getOutputStream());
// 设置excel第一列
WritableSheet sheet = book.createSheet("出纳付款", 0);
Label label = new Label(0, 0, "序号", formatTitle);
sheet.addCell(label);
label = new Label(1, 0, "公司/部门", formatTitle);
sheet.addCell(label);
label = new Label(2, 0, "凭证编号", formatTitle);
sheet.addCell(label);
label = new Label(3, 0, "出/收款行", formatTitle);
sheet.addCell(label);
label = new Label(4, 0, "出/收款账户", formatTitle);
sheet.addCell(label);
label = new Label(5, 0, "对方开户行", formatTitle);
sheet.addCell(label);
label = new Label(6, 0, "对方账户", formatTitle);
sheet.addCell(label);
label = new Label(7, 0, "金额", formatTitle);
sheet.addCell(label);
label = new Label(8, 0, "年月", formatTitle);
sheet.addCell(label); // 设置单元格宽度
sheet.setColumnView(0, 10);
sheet.setColumnView(1, 15);
sheet.setColumnView(2, 20);
sheet.setColumnView(3, 20);
sheet.setColumnView(4, 20);
sheet.setColumnView(5, 20);
sheet.setColumnView(6, 20);
sheet.setColumnView(7, 15);
sheet.setColumnView(8, 15);
if (list != null && list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
Object[] temp = (Object[]) list.get(i);
label = new Label(0, i + 1, i + 1 + "", formatBody);// 文件序号
sheet.addCell(label);
if (temp[0] == null) {
temp[0] = "";
}
label = new Label(1, i + 1, temp[0] + "", formatBody);// 公司/部门
sheet.addCell(label);
if (temp[1] == null) {
temp[1] = "";
}
label = new Label(2, i + 1, temp[1] + "", formatBody);// 凭证编号
sheet.addCell(label);
if (temp[2] == null) {
temp[2] = "";
}
label = new Label(3, i + 1, temp[2] + "", formatBody);// 出/收款行
sheet.addCell(label);
if (temp[3] == null) {
temp[3] = "";
}
label = new Label(4, i + 1, temp[3] + "", formatBody);// 出/收款账户
sheet.addCell(label);
if (temp[4] == null) {
temp[4] = "";
}
label = new Label(5, i + 1, temp[4] + "", formatBody);// 对方开户行
sheet.addCell(label);
if (temp[5] == null) {
temp[5] = "";
}
label = new Label(6, i + 1, temp[5] + "", formatBody);// 对方账户
sheet.addCell(label);
if (temp[6] == null) {
temp[6] = "";
}
label = new Label(7, i + 1, temp[6] + "", formatBody);// 金额
sheet.addCell(label);
if (temp[7] == null) {
temp[7] = "";
}
label = new Label(8, i + 1, temp[7] + "", formatBody);// 月份
sheet.addCell(label); }
}
} catch (Exception e) {
e.printStackTrace();
} finally {
// 写出并关闭流
if (book != null) {
try {
book.write();
book.close(); } catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
} catch (WriteException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}*/贴个例子给你,研究研究