国产一级a片免费看高清,亚洲熟女中文字幕在线视频,黄三级高清在线播放,免费黄色视频在线看

打開APP
userphoto
未登錄

開通VIP,暢享免費電子書等14項超值服

開通VIP
List導(dǎo)入Excel文件
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop.Excel;
using System.Web;
using System.IO;
using eName.App.Config;
using System.Data.OleDb;
using System.Data.Odbc;
using ServerHoldUnlock.Info.Table;
namespace ServerHoldUnlock.Libs
{
 public class Excels
 {
  public string CopyExcel()
  {
   string name = DateTime.Now.ToString("yyyyMMddHHmmss");
   string path = string.Format(AppSetting.Path,name);
   System.IO.File.Copy(System.Web.HttpContext.Current.Server.MapPath("~/App_Data/Excel/Sample.xls"), System.Web.HttpContext.Current.Server.MapPath(path));
   return name;
  }
  public void DateToExcel(List<ServerHoldUnlockTable> list, string name)
  {
   string path = string.Format(AppSetting.Path, name);
   string strCon = string.Format("Provider = Microsoft.Jet.OLEDB.4.0 ; Data Source ={0};Extended Properties=Excel 8.0", System.Web.HttpContext.Current.Server.MapPath(path));
   OleDbConnection myConn = new OleDbConnection(strCon);
   try
   {
    myConn.Open();
    for (int i = 0; i < list.Count; i++)
    {
     string sql = string.Format("INSERT INTO [Sheet1$] VALUES('{0}','{1}')", list[i].Domain, list[i].ICP);
     using (OleDbCommand comm = new OleDbCommand(sql, myConn))
     {
      comm.ExecuteNonQuery();
     }
    }
    myConn.Close();
    myConn.Dispose();
   }
   catch
   {
    myConn.Close();
    myConn.Dispose();
   }
  }
  /// <summary>
  /// 從web頁面下載文件
  /// </summary>
  /// <param name="strFile">要下載文件的絕對路徑</param>
  public void DownloadFile(string strFile)
  {
   HttpContext.Current.Response.Clear();
   HttpContext.Current.Response.ContentType = "application/octet-stream";
   HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=\"" + HttpUtility.UrlEncode(Path.GetFileName(strFile).Trim()) + "\"");
   HttpContext.Current.Response.Flush();
   HttpContext.Current.Response.WriteFile(strFile);
   HttpContext.Current.Response.End();
  }
 }
}
事先要創(chuàng)建好Excel的模板,程序復(fù)制調(diào)用
本站僅提供存儲服務(wù),所有內(nèi)容均由用戶發(fā)布,如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請點擊舉報
打開APP,閱讀全文并永久保存 查看更多類似文章
猜你喜歡
類似文章
Excel導(dǎo)入DataSet - 生 - 博客園
讀取EXCEL的數(shù)據(jù)到datagridview
C#操作Excel(讀取)
C# 將數(shù)據(jù)導(dǎo)出到Excel匯總
asp.net常用javascript封裝代碼
網(wǎng)站安全性:C#防SQL注入代碼的實現(xiàn)方法 - 51CTO.COM
更多類似文章 >>
生活服務(wù)
分享 收藏 導(dǎo)長圖 關(guān)注 下載文章
綁定賬號成功
后續(xù)可登錄賬號暢享VIP特權(quán)!
如果VIP功能使用有故障,
可點擊這里聯(lián)系客服!

聯(lián)系客服