用字符串作为输入在c#中创建简单的excel表 [英] creating simple excel sheet in c# with strings as input

查看:11
本文介绍了用字符串作为输入在c#中创建简单的excel表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在用 C# 创建 EXcel 表.

I am working on creating EXcel sheet in C#.

No Of columns:4
Name of columns: SNO, Name, ID, Address

行数没有限制.

         SNO   Name      ID   Address
          1     A         1122  XXXX
          2     B         2211  YYYY


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

我有字符串作为输入

       string sno, string name, string Id, string address

我实际上是 C# 背景的新手.

I am actually new to C# background.

任何人都可以分享他们对它的看法,例如需要的 dll 等.

Can any one share their view on it like dlls needed etc.

谢谢

推荐答案

如果您包含对 Excel Interop 你可以在你的系统上安装 Office 后做任何你想做的事情.

If you include a reference to Excel Interop you can do whatever you please having Office installed on your system.

一个小例子:

using Excel = Microsoft.Office.Interop.Excel;

Excel.Application excel = new Excel.Application();
excel.Visible = true;
Excel.Workbook wb = excel.Workbooks.Open(excel_filename);
Excel.Worksheet sh = wb.Sheets.Add();
sh.Name = "TestSheet";
sh.Cells[1, "A"].Value2 = "SNO";
sh.Cells[2, "B"].Value2 = "A";
sh.Cells[2, "C"].Value2 = "1122";
wb.Close(true);
excel.Quit();            

这篇关于用字符串作为输入在c#中创建简单的excel表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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