asp.net合并excel
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.OleDb; //导入命名空间
using System.IO;
using Excel = Microsoft.Office.Interop.Excel;
using System.Reflection;
using System.Data;
using EnterExcel.BLL;
using EnterExcel.Models;
public partial class JoinExcel : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack) { }
}
private static List<string> listFiles = new List<string>();
List<Pencil> pencilList = new List<Pencil>();
//“将Excel添加到集合中”事件
protected void btnAdd_Click(object sender, EventArgs e)
{
listFiles.Add(this.fuSearchExcel.PostedFile.FileName);
}
//“导入Excel到界面”事件
protected void btnJoinExcel_Click(object sender, EventArgs e)
{
//遍历集合
foreach (string listFile in listFiles)
{
//将Excel路径循环赋给方法
DataTable dt = CreateDataSource(listFile);
foreach (DataRow row in dt.Rows)
{
Pencil pencil = new Pencil();
pencil.Name = row[0].ToString();
pencil.Type = row[1].ToString();
pencil.Number = row[2].ToString();
pencil.Unit = row[3].ToString();
pencilList.Add(pencil);
}
}
this.gvInfo.DataSource = LoadExcelFiles(pencilList);
this.gvInfo.DataBind();
listFiles.Clear();
}
List<Pencil> list = new List<Pencil>();
public List<Pencil> LoadExcelFiles(List<Pencil> pencilList)
{
Pencil p = null;
for (int i = 0; i < pencilList.Count; i++)
相关文档:
1. aspx页面端代码:
<div class="gv-footer">
<asp:LinkButton ID="btFirstPage" runat="server" CommandArgument="first" OnClick ="PagerButton_Click">首页</asp:LinkButton>
<asp:Lin ......
最近在用用户控件时,引用户控件的页面有时候会和用户控件进行数据的交互,网上好像很多人不知道何获取
写个例子说明一下
取得用户控件里面的控件并进行赋值
用户控件aspx页代码
<%@ Control Language="C#" AutoEventWireup="true" CodeFile="HeadPanel.ascx.cs" Inherits="HeadPanel" %>
& ......
在BS项目中,某个aspx页面需要引用外部脚本文件,通过在页面head节<script language="" src="">方式引用指定的js之后,仍然无效。通过alert方式调试,发现是由于js文件编码与js文件内容不符。由于js文件中包含中文注释,所以需要设置js文件为可识别中文的gb2312编码。其方法在网上也讲述,以下为网摘内容:
&n ......
在今天,MVC(Model-View-Controller)设计模式与测试驱动开发方法(Test-Driven Development 简称TDD)被广泛应用于企业级WEB应用的开发中。MVC设计模式强制我们将应用分解成三个部分:模型(Model)负责业务数据的存储及管理,视图(View)负责呈现数据,并为用户提供与系统交互的界面接口,而控制器(Controller)则负责将用户动作 ......
新手如何学习c#、asp.net、ado.net和.NET
如果你已经有较多的面向对象开发经验,跳过以下这两步:
第一步 掌握一门.NET面向对象语言,C#或VB.NET。
在没系统学过一门面向对象(OO)语言的前提下去学ASP.NET。
ASP.NET是一个全面向对象的技术,不懂OO,那绝对学 ......