• 全部
  • C#综合技术
  • C#互联网桌面应用
  • AppLauncher
  • WinForm&WPF
  • C#开发新技术
  • 问答

在c#中能不能动态的生成一个excel文件,向里边添加数据?

yesman 2002-04-13 06:56:56
很急
...全文
53 点赞 收藏 3
写回复
3 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
dingsb 2002-04-13
using Excel;
class Excell
{ public static int Main()
{ Application exc = new Application();
Workbooks workbooks = exc.Workbooks;
_Workbook workbook = workbooks.Add(XlWBATemplate.xlWBATWorksheet);
Sheets sheets = workbook.Worksheets;
_Worksheet worksheet = (_Worksheet) sheets.get_Item(1);
Range range1 = worksheet.get_Range("C1","C1");
exc.Visible=true;
const int nCells = 1;
Object[] args1 = new Object[1];
args1[0] = nCells;
range1.Value2=100;
}

www.online.com.cn里面有
回复
wenzm 2002-04-13
可以吧,因为都是VBA编程啊
一下是一段C#中操作Word的代码,你看看有没有用
using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

if (this.openFileDialog1.ShowDialog() == DialogResult.OK)
{
object fileName = openFileDialog1.FileName;
object readOnly = false;
object isVisible = true;
object missing = System.Reflection.Missing.Value;

// WordApp.Activate();
WordApp.Visible = true;

Word.Document aDoc = WordApp.Documents.Open(ref fileName, ref missing,ref readOnly,
ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref isVisible);

aDoc.Activate();

WordApp.Selection.TypeText("Copyright C# Corner");
WordApp.Selection.TypeParagraph();

}
回复
saucer 2002-04-13
看看这篇文章

http://support.microsoft.com/default.aspx?scid=kb;EN-US;Q302084
回复
相关推荐
发帖
C#
创建于2007-09-28

10.5w+

社区成员

.NET技术 C#
申请成为版主
帖子事件
创建了帖子
2002-04-13 06:56
社区公告

让您成为最强悍的C#开发者