使用C#创建Excell文件 [英] Create a Excell file with C#

查看:104
本文介绍了使用C#创建Excell文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好!


我想用C#创建一个Excell文件。


我使用excell库我可以创建excell文件没有正确创建。


当我想打开文件时,excell说这个文件有错误!

解决方案

检查一下它在我的结束时运作良好 


添加对项目的引用 - Microsoft.Office.Interop.Excel


< pre class ="prettyprint"style =""> try
{
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Add();
wb.SaveAs(@" D:\ File File.xlsx");
wb.Close();
}
catch(exception ex){string errormsg = ex.ToString();}




Hello every body!

I want to create a Excell file with C#.

I use excell library and I could create excell file it was not created correctly.

when I want to open the file,excell says this file has error!

解决方案

Check this it works well at my end 

Add Reference to your project - Microsoft.Office.Interop.Excel

try
{
var app = new Microsoft.Office.Interop.Excel.Application();
var wb = app.Workbooks.Add();
wb.SaveAs(@"D:\File Path.xlsx");
wb.Close();
}
catch(Exception ex){string errormsg = ex.ToString();}



这篇关于使用C#创建Excell文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆