我正在使用 C# 创建 EXcel 工作表。
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# 背景的新手。
任何人都可以分享他们对它的看法,比如需要 dll 等。
谢谢
最佳答案
如果您包含对 Excel Interop 的引用在系统上安装 Office,您可以为所欲为。
一个小例子:
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# - 使用字符串作为输入在 C# 中创建简单的 Excel 工作表,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10100901/