标题:[特急]怎么用ASP导出数据到EXCEL
只看楼主
foxrain
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-3-18
 问题点数:0 回复次数:4 
[特急]怎么用ASP导出数据到EXCEL

我写了个这样的代码: Response.Buffer = TRUE Response.AddHeader "Content-Disposition", "attachment; filename=excel.xls" Response.contentType="application/vnd.ms-excel" 可输出一大串数字到EXCEL里就变成科学计数法了,后面几位数也都变成0 网上看到一个这样的代码: <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> <input type="hidden" name="out_excel" onclick="AutomateExcel();" value="导出到excel" class="notPrint"> 可就是输不出 大侠们帮帮我 怎么输出后控制EXCEL里显示的格式

搜索更多相关主题的帖子: EXCEL ASP 数据 var 
2005-04-27 15:36
foxrain
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-3-18
得分:0 
2005-04-27 15:40
foxrain
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2005-3-18
得分:0 
为什么?
不见有人回答呢?
2005-04-27 15:59
yms123
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:209
帖 子:12488
专家分:19042
注 册:2004-7-17
得分:0 
没使过ASP导出EXCEl数据。
2005-04-27 21:08
surnfu
Rank: 1
等 级:新手上路
帖 子:102
专家分:0
注 册:2005-3-21
得分:0 
Sub PrintExcel
 
  SetHeaders "ClassData" &amp; month(now) &amp; "_" &amp; day(now) &amp; ".xls", "Application/vnd.excel"
  
  Response.Write "&lt;html xmlns:x=""urn:schemas-microsoft-com:office:excel""&gt;"
  Response.Write "&lt;head&gt;"
  Response.Write "&lt;!--[if gte mso 9]&gt;&lt;xml&gt;"
  Response.Write "&lt;x:ExcelWorkbook&gt;"
  Response.Write "&lt;x:ExcelWorksheets&gt;"
  Response.Write "&lt;x:ExcelWorksheet&gt;"
  Response.Write "&lt;x:Name&gt;EC Report&lt;/x:Name&gt;"
  Response.Write "&lt;x:WorksheetOptions&gt;"
  Response.Write "&lt;x:Print&gt;"
  Response.Write "&lt;x:ValidPrinterInfo/&gt;"
  Response.Write "&lt;/x:Print&gt;"
  Response.Write "&lt;/x:WorksheetOptions&gt;"
  Response.Write "&lt;/x:ExcelWorksheet&gt;"
  Response.Write "&lt;/x:ExcelWorksheets&gt;"
  Response.Write "&lt;/x:ExcelWorkbook&gt;"
  Response.Write "&lt;/xml&gt;"
  Response.Write "&lt;![endif]--&gt; "
  Response.Write "&lt;/head&gt;"
  Response.Write "&lt;body&gt;"
  
  PrintTable "&lt;td&gt;","&lt;/td&gt;","&lt;tr&gt;","&lt;/tr&gt;","&lt;table&gt;","&lt;/table&gt;"
  
  Response.Write "&lt;/body&gt;"
  Response.Write "&lt;/html&gt;"
 End Sub

http://
2005-04-28 06:40



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-16847-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.099784 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved