宁静致远

------------------------------------------------------------------------------------

VC知识库BLOG 首页 新随笔 联系 聚合 登录
  45 Posts :: 0 Stories :: 112 Comments :: 1 Trackbacks

公告

-----000来了哈000-----

留言簿(0)

随笔分类

随笔档案

文章档案

相册

技术FAQ

搜索

最新评论

阅读排行榜

评论排行榜

 用C#操作Excel
1。新建c#控制台工程:textexcel:;
2。插入「Microsoft  Excel 10.0 Object Library」;
3。修改class1.cs,如下:
   using System;
 using System.Reflection;

 namespace ExcelTest
 {
     class Class1
     {
         static void Main()
         {
                    /*启动excel*/
             Excel.Application app = new Excel.Application();
             Excel._Workbook wb = app.Workbooks.Add(Missing.Value);
             wb.Application.Visible = true;
              
                    /*填充内容*/
                    Excel._Worksheet ws = (Excel.Worksheet)wb.ActiveSheet;
             ws.Cells[1, 1] = "城市";
             ws.Cells[2, 1] = "上海";
             ws.Cells[3, 1] = "西安";
             ws.Cells[4, 1] = "沈阳";
             ws.Cells[1, 2] = "人口";
             ws.Cells[2, 2] = 1243455;
             ws.Cells[3, 2] = 8831177;
             ws.Cells[4, 2] = 8687422;

         }
     }
 }

posted on 2005-06-08 11:48 blog of vc_student 阅读(2078) 评论(1)  编辑 收藏

Feedback

# re: 用C#操作Excel 2008-05-09 11:34 ddkc_c
提示无法创建抽像类,晕倒啦

标题  
姓名  
主页
验证码 *
内容   
  登录  使用高级评论  Top
[使用Ctrl+Enter键可以直接提交]