乔山办公网我们一直在努力
您的位置:乔山办公网 > excel表格制作 > 如何将<em>ASP</em>页面中的表格生成一个Excel表,求源码-asp 生成excel,

如何将<em>ASP</em>页面中的表格生成一个Excel表,求源码-asp 生成excel,

作者:乔山办公网日期:

返回目录:excel表格制作


那是禁止了右键而已
简单的做法:
用IE打开,点文件--保存(看文件类型里有没有XLS格式,有的话选择;没有的话文件类型保存为“文本文件”格式)

然后,再打开文本文件,点文件--另存为-选择EXCEL格式

'给你个例子吧。保存为 asp文件运行看看。具体就在第一句。

<%Response.ContentType = "application/vnd.ms-excel" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<meta name="GENERATOR" content="Microsoft FrontPage 4.0">
<meta name="ProgId" content="FrontPage.Editor.Document">
<title>New Page 1</title>
</head>
<body>
<table border="0" width=100%>
  <tr>
    <td colspan="22" align=middle>PJ计画书</td>
  </tr>
  <tr>
    <td colspan="4">第版</td>
    <td colspan="18"></td>
  </tr>
</table>
<table border="1" width=100%>
  <tr>
    <td  colspan="3">案件No</td>
    <td  colspan="4"></td>
    <td  colspan="2">案件名</td>
    <td  colspan="13"></td>
  </tr>
  <tr>
    <td  colspan="3" >主管部门</td>
    <td  colspan="4" ></td>
    <td  colspan="2" >顾客</td>
    <td  colspan="13" ></td>
  </tr>
  <tr>
    <td  colspan="3" >PJ责任者</td>
    <td  colspan="4" ></td>
    <td  colspan="2" >営业担当</td>
    <td  colspan="4" ></td>
    <td  colspan="2" >纳期</td>
    <td  colspan="3" ></td>
    <td  colspan="2" >事业种别</td>
    <td  colspan="2" ></td>
  </tr>
  <tr rowspan="2">
    <td colspan="3"  rowspan="2">请负金额</td>
    <td  colspan="4"  rowspan="2"></td>
    <td  colspan="2"  rowspan="2">开発原価</td>
    <td  colspan="4"  rowspan="2"></td>
    <td  colspan="2" >社员e799bee5baa6e78988e69d83338费</td>
    <td  colspan="2" >外注费</td>
    <td  colspan="2" >部材费</td>
    <td  colspan="3">冲PJ番号</td>
    <tr><td  colspan="2" ></td>
        <td  colspan="2" ></td>
        <td  colspan="2" ></td>
        <td  colspan="3"></td>
    </tr>    
  </tr>
  <tr>
    <td colspan="3" >案件の概要</td>
    <td colspan="19" ></td>
  </tr>
  <tr>
    <td   colspan="22"></td>
  </tr>
  <tr>
    <td   colspan="2">SUB案件</td>
    <td  >工程</td>
    <td   colspan="2">责任者</td>
    <td   colspan="3">期间</td>
    <td   colspan="2">総工数(H)</td>
    <td   colspan="3">アウトプット</td>
    <td  >业务管理适用</td>
    <td  colspan="5">要员</td>
    <td >外注</td>
    <td  colspan="2">実绩终了日</td>
  </tr>
  <tr>
    <td  colspan="2"></td>
    <td ></td>
    <td  colspan="2"></td>
    <td  colspan="3"></td>
    <td  colspan="2"></td>
    <td  colspan="3"></td>
    <td ></td>
    <td  colspan="5"></td>
    <td ></td>
    <td  colspan="2"></td>
  </tr>
  <tr>
    <td  colspan="22">マイルストーン</td>
  </tr>
  <tr>
    <td  colspan="7">设计検证完了</td>
    <td  colspan="8">予定</td>
    <td  colspan="7">実绩</td>
  </tr>
 <tr>
    <td  colspan="7"></td>
    <td  colspan="8"></td>
    <td  colspan="7"></td>
  </tr>
  <tr>
    <td  colspan="3">规模见积の根拠</td>
    <td  colspan="19"></td>
  </tr>
 <tr>
    <td  colspan="7">品质目标</td>
    <td  colspan="8">目标</td>
    <td  colspan="7">実绩</td>
  </tr>
   <tr>
    <td  colspan="7">故障率</td>
    <td  colspan="8"></td>
    <td  colspan="7"></td>
  </tr>
  <tr>
    <td  colspan="7">不稼动率</td>
    <td  colspan="8"></td>
    <td  colspan="7"></td>
  </tr>
   <tr>
    <td  colspan="7">プログラム完成度</td>
    <td  colspan="8"></td>
    <td  colspan="7"></td>
  </tr>
   <tr>
    <td  colspan="7"></td>
    <td  colspan="8"></td>
    <td  colspan="7"></td>
  </tr>
  <tr>
    <td  colspan="4">品质目标设定の根拠</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="5"></td>
    <td  colspan="3">予定日</td>
    <td  colspan="4"></td>
    <td  colspan="2">実施日</td>
    <td  colspan="3"></td>
    <td  colspan="2">承认者</td>
    <td  colspan="3"></td>
  </tr>
  <tr>
    <td  colspan="5">要求事项レビュー(记録)</td>
    <td  colspan="17"></td>
  </tr>
  <tr>
    <td  colspan="5">管理手顺</td>
    <td  colspan="17"></td>
  </tr>
  <tr>
    <td  colspan="5">PJ区分</td>
    <td  colspan="17"></td>
  </tr>
  <tr>
    <td  colspan="5">PJ入力情报</td>
    <td  colspan="17"></td>
  </tr>
 <tr>
    <td  colspan="5">纳入物品</td>
    <td  colspan="17"></td>
  </tr>
  <tr>
    <td  colspan="5">合否判断基准</td>
    <td  colspan="17"></td>
  </tr>
 <tr>
    <td  colspan="5">设计制造の出荷判定责任者、またはサービスの合否判断责任者</td>
    <td  colspan="17"></td>
  </tr>
 <tr>
    <td  colspan="5">PJ终了要件</td>
    <td  colspan="17"></td>
  </tr>
  <tr>
    <td  colspan="4">作业标准</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="4">作业手顺</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="4">事前教育</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="4">外注管理方法</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="4">顾客所有物</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="4">准备机器及び调达计画</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="4">PJ会议</td>
    <td  colspan="18"></td>
  </tr>
 <tr>
    <td  colspan="4">计画承认</td>
    <td  colspan="14"></td>
    <td  colspan="4"></td>
  </tr>
  <tr>
    <td  colspan="4">PJ终了承认</td>
    <td  colspan="5"></td>
    <td  colspan="2">予定日</td>
    <td  colspan="5"></td>
    <td  colspan="2">実绩日</td>
    <td  colspan="4"></td>
  </tr>
  <tr>
    <td  colspan="4">记事栏</td>
    <td  colspan="18"></td>
  </tr>
  <tr>
    <td  colspan="4">変更理由</td>
    <td  colspan="18"></td>
  </tr>
</table>
</body>
</html>

代码发到那?
/// <summary>
/// 导出DataGridView的数据到Excel表中e799bee5baa6e997aee7ad94e58685e5aeb9363
/// </summary>
/// <param name="m_DataView"></param>
public static void DataToExcel(DataGridView m_DataView)
{
SaveFileDialog kk = new SaveFileDialog();
kk.Title = "保存EXECL文件";
kk.Filter = "EXECL文件(*.xls) |*.xls|所有文件(*.*) |*.*";
kk.FilterIndex = 1;
if (kk.ShowDialog() == DialogResult.OK)
{
string FileName = kk.FileName;// + ".slsx";
if (File.Exists(FileName))
File.Delete(FileName);
FileStream objFileStream;
StreamWriter objStreamWriter;
string strLine = "";
objFileStream = new FileStream(FileName, FileMode.OpenOrCreate, FileAccess.Write);
objStreamWriter = new StreamWriter(objFileStream, System.Text.Encoding.Unicode);
for (int i = 0; i < m_DataView.Columns.Count; i++)
{
if (m_DataView.Columns[i].Visible == true)
{
strLine = strLine + m_DataView.Columns[i].HeaderText.ToString() + Convert.ToChar(9);
}
}
objStreamWriter.WriteLine(strLine);
strLine = "";

for (int i = 0; i < m_DataView.Rows.Count; i++)
{
if (m_DataView.Columns[0].Visible == true)
{
if (m_DataView.Rows[i].Cells[0].Value == null)
strLine = strLine + " " + Convert.ToChar(9);
else
strLine = strLine + m_DataView.Rows[i].Cells[0].Value.ToString() + Convert.ToChar(9);
}
for (int j = 1; j < m_DataView.Columns.Count; j++)
{
if (m_DataView.Columns[j].Visible == true)
{
if (m_DataView.Rows[i].Cells[j].Value == null)
strLine = strLine + " " + Convert.ToChar(9);
else
{
string rowstr = "";
rowstr = m_DataView.Rows[i].Cells[j].Value.ToString();
if (rowstr.IndexOf("\r\n") > 0)
rowstr = rowstr.Replace("\r\n", " ");
if (rowstr.IndexOf("\t") > 0)
rowstr = rowstr.Replace("\t", " ");
strLine = strLine + rowstr + Convert.ToChar(9);
}
}
}
objStreamWriter.WriteLine(strLine);
strLine = "";
}
objStreamWriter.Close();
objFileStream.Close();
}
}
调用
Main_BodyExcel.DataToExcel(gwSum);

<%
dim excelstring
dim excelstr
dim excelstr2
dim head
excelstring = ""
head = "Sn" & "," & "Reason" & "," & "Empid" & "," & "Empname" & "," & "Ext" & "," & "Depname" excel="creat"
If excel<>""
Then
Set rs2 = Server.CreateObject ("ADODB.Recordset")
sql2 = "Select * from value_table "
rs2.open sql2,conn,1,3 do while not rs2.eof excelstr =" " & rs2(0) & """,""" & rs2(1) & """,""" & rs2(2) & """,""" & rs2(3) & """,""" & rs2(4) & """,""" & rs2(5) & """" excelstr2 = excelstr2 & Chr(13) & excelstr rs2.movenext loop excelstring = head &Chr(13)& excelstr2 'response.Write(excelstring) 'rs2.close
Set rs2=Nothing
set fs = CreateObject("scripting.FileSystemObject")
set exc = fs.OpenTextFile(server.MapPath("excel.csv"),2,True) exc.write(excelstring) if fs.FileExists(Server.MapPath("excel.csv"))
then Response.Write("<a href=excel.csv>报表已经生成,点击查e79fa5e98193e58685e5aeb9362看</a>") 'Response.write(excelstring) else Response.Write("生成报表失败!") end if End if%>

相关阅读

关键词不能为空
极力推荐

ppt怎么做_excel表格制作_office365_word文档_365办公网