我正在尝试将Excel文件发送回用户.在某种程度上,即使它是空的,我的excel文件也会被破坏.当我打开文件时,Excel告诉我该文件已损坏.
如果我删除
response.getOutputStream().write(excelService.exportEventsToCSV());
Run Code Online (Sandbox Code Playgroud)
我得到一个空的excel文件.
@RequestMapping(value = "/events/excel", method = RequestMethod.GET)
public void getEventsAsExcel(HttpServletResponse response) {
try {
response.setHeader("Content-disposition", "attachment; filename=test.xls");
response.getOutputStream().write(excelService.exportEventsToCSV());
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
Run Code Online (Sandbox Code Playgroud)
我的XML生成非常简单.只是空文件
@Override
public byte[] exportEventsToCSV() {
try {
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet worksheet = workbook.createSheet("POI Worksheet");
HSSFCellStyle cellStyle = workbook.createCellStyle();
workbook.write(fileOut);
return workbook.getBytes();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
return null;
}
Run Code Online (Sandbox Code Playgroud)
请任何建议.我正在考虑Springs Excel视图,但我不想要一个视图.只是一个下载的文件.
您好,我正在学习AngularJS文档中的本教程。
我正在尝试使用这种方法来学习这一点。
您将需要在系统上运行http服务器。Mac和Linux计算机通常预装了Apache,但是如果尚未安装Apache,则可以使用node运行scripts / web-server.js,这是一个简单的捆绑式http服务器。
我的服务器已启动,但是在localhost:8000(运行它的端口)上发生的唯一事情就是列出了文件。
如何使用Node.js进行部署?
当我在浏览器中导航到localhost:8000时,这是我的服务器日志。
112-108-15:脚本phe $ ./web-server.js
运行在http:// localhost:8000 /
GET / Mozilla / 5.0(Macintosh; Intel Mac OS X 10_8_4)上的Http Server AppleWebKit / 537.36(KHTML,如Gecko )Chrome / 29.0.1547.65 Safari / 537.36
GET / Mozilla / 5.0(Macintosh; Intel Mac OS X 10_8_4)AppleWebKit / 537.36(KHTML,如Gecko)Chrome / 29.0.1547.65 Safari / 537.36
如果我在chrome中运行此代码:
for(var i in window){console.log(i)}
Run Code Online (Sandbox Code Playgroud)
我得到了很多属性,如下所示.
但是,如果我运行此代码:
console.log(window.hasOwnProperty("parseInt"))
console.log(window.hasOwnProperty("undefined"))
Run Code Online (Sandbox Code Playgroud)
我得到true两个.
如何.hasOwnProperty()返回true,但它不会出现在for-in循环产生的属性列表中?
循环结果:
top VM1531:2
window VM1531:2
location VM1531:2
external VM1531:2
chrome VM1531:2
document VM1531:2
getInnerFunction VM1531:2
theInnerFunction VM1531:2
__commandLineAPI VM1531:2
i VM1531:2
speechSynthesis VM1531:2
localStorage VM1531:2
sessionStorage VM1531:2
applicationCache VM1531:2
webkitStorageInfo VM1531:2
indexedDB VM1531:2
webkitIndexedDB VM1531:2
crypto VM1531:2
CSS VM1531:2
performance VM1531:2
console VM1531:2
devicePixelRatio VM1531:2
styleMedia VM1531:2
parent VM1531:2
opener VM1531:2
frames VM1531:2
self VM1531:2
defaultstatus VM1531:2
defaultStatus VM1531:2
status VM1531:2 …Run Code Online (Sandbox Code Playgroud) 在 freemarker 中比较数字最优雅的是什么?
<#if (variable = 2) ></#if>
Run Code Online (Sandbox Code Playgroud)
这将不包括空检查?
如果我这样做
<#if (variable! = 2) ></#if>
Run Code Online (Sandbox Code Playgroud)
然后freemarker会抱怨不同的类型。
我最终这样做了
<#if (variable!?html = "2") ></#if>
Run Code Online (Sandbox Code Playgroud)
但我想这不是这样做的方式吗?如何将数字与 freemarker 中的空检查进行比较?
我正在尝试impress.js但我想我有办法改变一些幻灯片的身体背景颜色.我想我的前3张幻灯片有不同的背景,其余的.
如何检查例如字符串数组是否包含字符串?
<xsl:if test="inArray('a', $array)"></xsl:if>
Run Code Online (Sandbox Code Playgroud) 如果我删除"distinct"或"order by",则此查询有效,但它不能合并.我想跟随例子.你能解释一下吗?
String queryString = "select distinct event.county from Event as event order by event.county.county"
[main] - [ERROR] SqlExceptionHelper.logExceptions():144 >> ERROR: for SELECT DISTINCT, ORDER BY expressions must appear in select list
Position: 215
Run Code Online (Sandbox Code Playgroud)
生成的SQL
select distinct county1_.Id as Id4_, county1_.County as County4_ from Event event0_ inner join County county1_ on event0_.CountyID=county1_.Id cross join County county2_ where event0_.CountyID=county2_.Id order by county2_.County
Run Code Online (Sandbox Code Playgroud) 我正在从控制器下载文件.这是行不通的.这是因为文件名中的",".如果我从名称中删除","它将起作用.对此有任何解决方法吗?我应该做String.replace(",""").肯定有更好的办法?
response.setHeader("Content-Disposition", "inline; filename=" + "abbbbababbaababba.4.1.2013,aakdfhfdf.xlsx");
Run Code Online (Sandbox Code Playgroud)
完整的方法
@RequestMapping(value = "/newsimage/{newsImageId} ", method = RequestMethod.GET)
public void getImage(HttpServletRequest request, HttpServletResponse response, @PathVariable long newsImageId) {
NewsImage newsImage = newsImageService.findById(newsImageId);
String fileName = newsImage.getFileName();
response.setHeader("Content-Disposition", "inline; filename=" + "abbbbababbaababba.4.1.2013,aakdfhfdf.xlsx");
response.setContentType(newsImage.getContentType());
// response.setHeader("Content-Disposition", "attachment;filename=" + newsImage.getFileName());
OutputStream out;
try {
out = response.getOutputStream();
out.write(newsImage.getData());
out.flush();
} catch (IOException e) {
logger.error(e.getMessage());
}
}
Run Code Online (Sandbox Code Playgroud) 我怎样才能获得xslt中当前的一周.像星期一,星期二...... 0,1,2也是可以接受的.
我怎么能在XSLT中做到这一点?
我在另一个帖子中找到了thoose示例,但我没有得到它.
0 == '0' // true
Run Code Online (Sandbox Code Playgroud)
0到左边我转换为false(唯一的数字).右边是一个非空字符串,它将转换为true.那么怎么可以假==真 - >真
我错过了什么?
编辑:很多抱怨.我不明白我的具体情况.(顶部的链接正是我复制和粘贴此案例的地方)
javascript ×2
xslt ×2
xslt-2.0 ×2
angularjs ×1
apache-poi ×1
freemarker ×1
hibernate ×1
hql ×1
http ×1
impress.js ×1
java ×1
jpa ×1
jpa-2.0 ×1
node.js ×1
response ×1
servlets ×1
spring ×1
spring-mvc ×1