关于ASP.NET访问Excel 电子表格的代码
来源:互联网 发布:淘宝数据分析那个免费 编辑:程序博客网 时间:2024/06/03 15:02
本文是关于ASP.NET访问Excel 电子表格的代码 C# Code
---------------------------------------------
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<script language="C#" runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C://exceltest.xls;" +
"Extended Properties=Excel 8.0;";
'You must use the $ after the object you reference in the spreadsheet
ADODataSetCommand myCommand = new ADODataSetCommand("SELECT * FROM [Sheet1$]", strConn);
DataSet myDataSet = new DataSet();
myCommand.FillDataSet(myDataSet, "ExcelInfo");
DataGrid1.DataSource = myDataSet.Tables["ExcelInfo"].DefaultView;
DataGrid1.DataBind();
}
</script>
<p><asp:Label id=Label1 runat="server">SpreadSheet Contents:</asp:Label></p>
<asp:DataGrid id=DataGrid1 runat="server"/>
VB.NET Code
----------------------------------------------
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim myDataset As New DataSet()
'You can also use the Excel ODBC driver I believe - didn't try though
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:/exceltest.xls;" & _
"Extended Properties=""Excel 8.0;"""
'You must use the $ after the object you reference in the spreadsheet
Dim myADODataSetCommand As New ADODataSetCommand("SELECT * FROM [Sheet1$]", strConn)
myADODataSetCommand.TableMappings.Add("Table", "ExcelTest")
myADODataSetCommand.FillDataSet(myDataset)
DataGrid1.DataSource = myDataset.Tables(0).DefaultView
DataGrid1.DataBind()
End Sub
</script>
<p><asp:Label id=Label1 runat="server">SpreadSheet Contents:</asp:Label></p>
<asp:DataGrid id=DataGrid1 runat="server"/>
---------------------------------------------
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<script language="C#" runat="server">
protected void Page_Load(Object Src, EventArgs E)
{
string strConn;
strConn = "Provider=Microsoft.Jet.OLEDB.4.0;" +
"Data Source=C://exceltest.xls;" +
"Extended Properties=Excel 8.0;";
'You must use the $ after the object you reference in the spreadsheet
ADODataSetCommand myCommand = new ADODataSetCommand("SELECT * FROM [Sheet1$]", strConn);
DataSet myDataSet = new DataSet();
myCommand.FillDataSet(myDataSet, "ExcelInfo");
DataGrid1.DataSource = myDataSet.Tables["ExcelInfo"].DefaultView;
DataGrid1.DataBind();
}
</script>
<p><asp:Label id=Label1 runat="server">SpreadSheet Contents:</asp:Label></p>
<asp:DataGrid id=DataGrid1 runat="server"/>
VB.NET Code
----------------------------------------------
<%@ Page Language="VB" %>
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.ADO" %>
<script language="VB" runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Dim myDataset As New DataSet()
'You can also use the Excel ODBC driver I believe - didn't try though
Dim strConn As String = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=C:/exceltest.xls;" & _
"Extended Properties=""Excel 8.0;"""
'You must use the $ after the object you reference in the spreadsheet
Dim myADODataSetCommand As New ADODataSetCommand("SELECT * FROM [Sheet1$]", strConn)
myADODataSetCommand.TableMappings.Add("Table", "ExcelTest")
myADODataSetCommand.FillDataSet(myDataset)
DataGrid1.DataSource = myDataset.Tables(0).DefaultView
DataGrid1.DataBind()
End Sub
</script>
<p><asp:Label id=Label1 runat="server">SpreadSheet Contents:</asp:Label></p>
<asp:DataGrid id=DataGrid1 runat="server"/>
- 关于ASP.NET访问Excel 电子表格的代码
- ASP.NET:访问Excel 电子表格
- ASP.NET:访问Excel电子表格
- ASP.NET:访问Excel电子表格
- ASP.NET:访问Excel 电子表格
- 关于asp.net访问Excel的问题
- Asp.net 导出EXCEL电子表格 工具类
- 关于asp.net与winform导出excel的代码
- 关于VB.NET与电子表格EXCEL编程的问题,我是这样解决的!
- asp.net访问excel
- asp.net 访问Excel的方法
- ASP.NET访问Excel受限的解决方法
- ASP.NET 访问Excel 失败的解决方法
- 利用ASP显示Excel电子表格
- excel 电子表格java代码片
- asp.net电子表格导出功能
- 关于Asp.net中使用以下代码导出Excel表格的问题
- 关于Asp.net中使用以下代码导出Excel表格的问题
- grub
- 网上的手游开发笔记,还不错
- 解决phpMyAdmin数据乱码问题
- 动态生成控件
- web中数据静态分页
- 关于ASP.NET访问Excel 电子表格的代码
- 端午节时看看搜索引擎的脸
- Linux经验备案录
- source code generators.
- 使用Microsoft Date And Time Picker Control 6.0(SP6)时要注意的小问题
- .NET 配置
- windows 上的命令行
- 写Form设计器尝试
- IT团队精神4要素