计算机与现代化 ›› 2011, Vol. 1 ›› Issue (4): 29-31.doi: 10.3969/j.issn.1006-2475.2011.04.009

• 数据库 • 上一篇    下一篇

在C# .NET下实现数据导入Excel的方法研究

苏庆,李忠良,吴伟民   

  1. 广东工业大学计算机学院可视计算实验室,广东 广州 510006
  • 收稿日期:2010-12-07 修回日期:1900-01-01 出版日期:2011-04-27 发布日期:2011-04-27

Research on Method of Export Data into Excel in C#.NET

SU Qing, LI Zhong-liang, WU Wei-min   

  1. Visualization in Scientific Computing Laboratory, Faculty of Computer, Guangdong University of Technology, Guangzhou 510006, China
  • Received:2010-12-07 Revised:1900-01-01 Online:2011-04-27 Published:2011-04-27

摘要: 在C# .NET下将DataGridView中的数据导入Excel表格,常用的方法是通过Excel的COM组件来实现在C#中和Excel交互。由于开发计算机和用户计算机上安装的Excel版本不同,经常会导致不兼容的现象。为了解决这个问题,本文提出利用反射技术来实现C#和Excel交互。在安装不同版本的Excel的机器上进行实验,结果表明该方案很好地解决版本兼容性问题。

关键词: 反射, COM组件, Excel

Abstract: In C# .NET, the commonly method of export the data in the component of DataGridView into Excel uses the Excel’s COM component to achieve it. But because the vision of Excel between the development machine and user’s machine installed maybe different, this method often leads to the phenomenon of incompatible. To solve this problem, the reflection technique is proposed to implement the interaction of C# and Excel. Through the experiment on the computer with different visions of Excel, the results show that this method can solve the problem of version compatibility very well. 

Key words: reflection, COM component, Excel

中图分类号: