【发布时间】:2014-10-13 11:32:49
【问题描述】:
我想创建一个保存在数据库中的路径。
这是我的代码。
@RequestMapping("import_excel")
@ResponseBody
public Map<String, ? extends Object> import_excel() {
modelMap.clear();
try {
HttpSession session = req.getSession();
HSSFWorkbook wb = new HSSFWorkbook();
HSSFSheet sheet = wb.createSheet("Export");
Row row1 = sheet.createRow((short) 3);
row1.createCell(0).setCellValue("Asset Number");
row1.createCell(1).setCellValue("Asset Barcode");
row1.createCell(2).setCellValue("Asset Name");
short i = 4;
Row row2 = sheet.createRow(i++);
row2.createCell(0).setCellValue(as.getCdas());
row2.createCell(1).setCellValue(as.getBcd());
row2.createCell(2).setCellValue(as.getNm());
FileOutputStream fileOut = new FileOutputStream(src + "/Export.xls");
wb.write(fileOut);
fileOut.close();
modelMap.put("success", true);
modelMap.put("rows", obj);
modelMap.put("count", count);
} catch (IOException ex) {
modelMap.put("success", false);
modelMap.put("msg", ex.getMessage());
}
return modelMap;
}
我要制作 FileOutputStream fileOut = new FileOutputStream(src + "/Export.xls");
使用我保存在 db 中的路径。所以如果我想更改路径,我只需在 db.xml 中更改即可。
我已经尝试了上面的代码,但似乎不起作用。
请帮我。谢谢:)
【问题讨论】:
-
src的值是多少?这不是你想要的吗? -
@Gagravarr src 是我要在数据库中调用的路径。
-
那么与您的数据库通信的代码在哪里?我没有看到任何 JDBC 调用或类似调用...看起来您错过了代码的关键部分!
标签: java excel apache-poi