生成excel问题

coo_key 2004-09-13 01:56:28
<%
Response.Buffer = true
Response.ContentType = "application/vnd.ms-excel"
%>

然后页面里面的table是不规则的
通过javascript填充

如果不要上面两行
发现可疑填充

加上后生成excel,发现填充结果没有生效,是不是加上Response.ContentType = "application/vnd.ms-excel" 后不能用javascript了?改成vbscript也不行
不知道怎么办,不知道谁碰到过
如果是填充
<%=...%>
就可以
...全文
255 24 打赏 收藏 转发到动态 举报
写回复
用AI写文章
24 条回复
切换为时间正序
请发表友善的回复…
发表回复
coo_key 2004-09-16
  • 打赏
  • 举报
回复
呵呵
找了一些规律
然后一个格子一个格子填充
快晕死了
觉得自己的方法好笨,不过也没办法了
呵呵
coo_key 2004-09-14
  • 打赏
  • 举报
回复
是的
我现在在重写一个填充方法..郁闷ing...
xjdawu 2004-09-13
  • 打赏
  • 举报
回复
补充,是样式表的选择器不起作用
xjdawu 2004-09-13
  • 打赏
  • 举报
回复
用样式表好像是不起作用的!变通的方法是直接把CSS写到标签的style属性里
ycted 2004-09-13
  • 打赏
  • 举报
回复
我用的也和 aspczlover(执子之手...) 差不多.导入后网格大小的样式是没有了.还需要自己调整.
coo_key 2004-09-13
  • 打赏
  • 举报
回复
测试结果:
首先,table定义的样式都没有了,比如网格大小等
其次,如果有合并格的话,会导致复杂不规范的表格生成很难看,打印的时候需要重新调整很久

不知道怎么解决
如果还要换一种方来来解决的话就麻烦了:(
请各位老大帮帮忙啊~~
coo_key 2004-09-13
  • 打赏
  • 举报
回复
刚才试了一下
如果是不规则的表格,则不能用这个方法..
正在找方法解决之
coo_key 2004-09-13
  • 打赏
  • 举报
回复

好的
我先试试,谢谢楼上的~~
aspczlover 2004-09-13
  • 打赏
  • 举报
回复
想修改那行那列你应该明白了把
在这个位置加这句就行
oSheet.Cells(1,2).Value="dd" '在某行某列赋予你所需要的值

oXL.Visible = true;
oXL.UserControl = true;
}
//-->
</SCRIPT>
aspczlover 2004-09-13
  • 打赏
  • 举报
回复
浏览器表格导出到Excel

<input type="hidden" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint">


<input type="button" name="out_word1" onclick="javascript:AutomateExcel() " value="导出到excel" class="notPrint">


<table id="data" width="200" border="1">
<tr>
<td>11</td>
<td>11</td>
</tr>
<tr>
<td>22</td>
<td>22</td>
</tr>
<tr>
<td>33</td>
<td>33</td>
</tr>
<tr>
<td>44 </td>
<td>44</td>
</tr>
</table>


<SCRIPT LANGUAGE="JavaScript">
<!--
function AutomateExcel()
{
// Start Excel and get Application object.
var oXL = new ActiveXObject("Excel.Application");
// Get a new workbook.
var oWB = oXL.Workbooks.Add();
var oSheet = oWB.ActiveSheet;
var table = document.all.data;
var hang = table.rows.length;

var lie = table.rows(0).cells.length;

// Add table headers going cell by cell.
for (i=0;i<hang;i++)
{
for (j=0;j<lie;j++)
{
oSheet.Cells(i+1,j+1).Value = table.rows(i).cells(j).innerText;
}

}
oXL.Visible = true;
oXL.UserControl = true;
}
//-->
</SCRIPT>
aspczlover 2004-09-13
  • 打赏
  • 举报
回复
呵呵 asp不能像在.net里那么随心所欲操作表格的
coo_key 2004-09-13
  • 打赏
  • 举报
回复
怎么直接导入?
在客户端new一个Excel.Application??
请具体解释一下~
ryuginka 2004-09-13
  • 打赏
  • 举报
回复
知己倒入就是了
redstorm11 2004-09-13
  • 打赏
  • 举报
回复
mark~~
coo_key 2004-09-13
  • 打赏
  • 举报
回复
那就是说我估计是对的了

有没有办法在asp服务端控制table控件阿
.net里面是可以的~
aspczlover 2004-09-13
  • 打赏
  • 举报
回复
直接导入到excel可以实现这个功能
aspczlover 2004-09-13
  • 打赏
  • 举报
回复
用了
Response.ContentType = "application/vnd.ms-excel"
客户端脚本就会失去作用
hrstudy 2004-09-13
  • 打赏
  • 举报
回复
你使用Excel格式输出网页后,系统就把它当成Excel格式嵌入文档了,能不能继续修改还真的不知道,要不你参考一下VBA,帮不上帮了。
coo_key 2004-09-13
  • 打赏
  • 举报
回复
比如
再.net里面
可以使table runat server
然后再服务端调,填充
不知道asp端有没有类似把table标签在服务端引用的办法。。:(
否则,全部重写代码太麻烦了,呵呵..拜托各位了
coo_key 2004-09-13
  • 打赏
  • 举报
回复
我感觉是
<%
Response.Buffer = true
Response.ContentType = "application/vnd.ms-excel"
%>
这个东西是服务端的,如果用客户端的javascript来执行,可能会没有执行到
但是我设定了
<meta http-equiv="Content-Type" content= application/vnd.ms-excel...之后
还是没有执行

不知道有没有可以在使用
<%
Response.Buffer = true
Response.ContentType = "application/vnd.ms-excel"
%>
的时候可以使用javascript的方法?
或者其他简单的替代方法
加载更多回复(4)

28,408

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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