急::servlet如何传送CSV文件到客户端,并且在客户端直接用excel打开??

chunfa1980 2004-04-05 12:13:30
我现在客户端有一些查询结果,为了解决速度问题,当用户在网页上点击打印按钮,我在服务器上生成CSV文件,然后把他传到客户端,并且传送结束直接在Excel显示数据,如何实现传送和直接在EXcel中显示呢,不要提示对话框,谢谢
...全文
80 23 打赏 收藏 转发到动态 举报
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
李秀国之印 2004-04-08
  • 打赏
  • 举报
回复
study
chunfa1980 2004-04-08
  • 打赏
  • 举报
回复
大家说说你们如何做的阿?让我也借鉴一下,谢谢!!!!!!!!
chunfa1980 2004-04-07
  • 打赏
  • 举报
回复
可是格式有没有好的办法?
另外打开的时候有提示保存,打开的对话框
我们头,不想要
liusoft 2004-04-06
  • 打赏
  • 举报
回复
客户端如果安装了Excel就会自动打开Excel并显示的:)
enling322 2004-04-06
  • 打赏
  • 举报
回复
o . .- .-
./ .--...
o .-------- $ .--
o 分 o / .......
' ..
o o o '........ ----
o 分 . --..
o o o . .---.. -
o . ' -.
o o / '
o 分 / ' ' '
\-----/....... . ' ' ' '
\ __/ - - -' ' ' '
' ' ' '
o ' ' ' '
' ' '
-..'.----------.
I ----------
/////////.

经典,请支持

http://expert.csdn.net/Expert/topic/2921/2921075.xml?temp=.9381983

http://expert.csdn.net/Expert/topic/2921/2921075.xml?temp=.9381983

http://expert.csdn.net/Expert/topic/2921/2921075.xml?temp=.9381983

http://expert.csdn.net/Expert/topic/2921/2921075.xml?temp=.9381983

http://expert.csdn.net/Expert/topic/2921/2921075.xml?temp=.9381983

http://expert.csdn.net/Expert/topic/2921/2921075.xml?temp=.9381983

http://expert.csdn.net/Expert/topic/2921/2921075.xml?temp=.9381983
CoolAbu 2004-04-06
  • 打赏
  • 举报
回复
格式估计通过程序很难控制。

mime-type中还有什么提示呀?
chunfa1980 2004-04-06
  • 打赏
  • 举报
回复
还是有提示的
<mime-mapping>
<extension>xls</extension>
<mime-type>text/msexcel</mime-type>-------------???application/msexcel
</mime-mapping>
<mime-mapping>
<extension>csv</extension>
<mime-type>text/msexcel</mime-type>-------------??appication/msexcel </mime-mapping>
chunfa1980 2004-04-06
  • 打赏
  • 举报
回复
httpServletResponse.setContentType("application/msexcel;charset=Shift_JIS");
httpServletResponse.setHeader("Content-disposition", "inline;filename=temp.csv");//MIME type for EXCEL doc


FileReader fr = new FileReader("F:/hysoft.csv");
PrintWriter pr = httpServletResponse.getWriter();
char c[] = new char[4096];
int read = 0;
while((read = fr.read(c)) != -1) {
pr.write(c,0,read);

}
fr.close();
pr.close();
chunfa1980 2004-04-06
  • 打赏
  • 举报
回复
excel数据格式怎么控制呢,?
谢谢
CoolAbu 2004-04-06
  • 打赏
  • 举报
回复
在你的webapp中WEB-INF\的web.xml中加入mime-type试试,在我这里这样就可以。没有弹出对话框

<mime-mapping>
<extension>xls</extension>
<mime-type>text/msexcel</mime-type>
</mime-mapping>
<mime-mapping>
<extension>csv</extension>
<mime-type>text/msexcel</mime-type>
</mime-mapping>
chunfa1980 2004-04-06
  • 打赏
  • 举报
回复
等待高人
chunfa1980 2004-04-06
  • 打赏
  • 举报
回复
response.setContentType("text/msexcel");
但是出现提示保存打开对话框?怎么办?另外如何控制excel中的数据格式阿
例如
1
1
1
all
我想让他们都靠右,如何处理,谢谢
java悠悠 2004-04-06
  • 打赏
  • 举报
回复
http://www.csdn.net/develop/Read_Article.asp?Id=22939
icy_csdn 2004-04-06
  • 打赏
  • 举报
回复
response.setContentType("text/msexcel");
icy_csdn 2004-04-06
  • 打赏
  • 举报
回复
试试这个
response.setcontenttype("text/msexcel");
chunfa1980 2004-04-06
  • 打赏
  • 举报
回复
等待中!!
chunfa1980 2004-04-05
  • 打赏
  • 举报
回复
各位,谁做过这些方面的,谈谈经验吧
vongood 2004-04-05
  • 打赏
  • 举报
回复
up
chunfa1980 2004-04-05
  • 打赏
  • 举报
回复
我还是鞋垫代码吧
servlet中
response.setcontenttype("text/csv");
但是他又提示对话框,我现在不想要,想让它直接调用excel 打开
fxywkj 2004-04-05
  • 打赏
  • 举报
回复
没有用过,应该有设置的!
加载更多回复(3)

81,092

社区成员

发帖
与我相关
我的任务
社区描述
Java Web 开发
社区管理员
  • Web 开发社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧