当前位置:软件学习 > Excel >>

C# 操作Excel

实现代码如下:

using System; 
using System.Collections.Generic; 
using System.Text; 
using System.Windows.Forms; 
// 引入OFFICE EXCEL命名空间 
using Excel = Microsoft.Office.Interop.Excel; 
using System.Reflection; 
using System.Data; 
using System.IO; 
using System.Diagnostics; 
using System.Collections; 
using System.Runtime.InteropServices; 

namespace TestLib 

    public class ExcelOperation 
    { 
        private DateTime beforeTime; //Excel启动之前时间 
        private DateTime afterTime; //Excel启动之后时间 
        Excel.Application myExcel = new Excel.Application(); 
        Excel.Workbook myBook; 
        Excel.Worksheet mySheet1; 
        Excel.Range range; 
        Excel.Range range1; 
        Excel.Range range2; 
        Excel.TextBox textBox; 
        public  int sheetCount = 1; //WorkSheet数量 
        private string sheetPrefixName = "页"; 

        
        #region 公共属性 
        /// <summary> 
        /// WorkSheet前缀名,比如:前缀名为“页”,那么WorkSheet名称依次为“页-1,页-2\” 
        /// </summary> 
        public string SheetPrefixName 
        { 
            set { this.sheetPrefixName = value; } 
        } 

        /// <summary> 
        /// WorkSheet数量 
        /// </summary> 
        public int WorkSheetCount 
        { 
            get { return myBook.Sheets.Count; } 
        } 

        #endregion 
        public 

补充:软件开发 , C# ,
CopyRight © 2012 站长网 编程知识问答 www.zzzyk.com All Rights Reserved
部份技术文章来自网络,