简体   繁体   English

如何打开Excel工作表和CSV文件?Excel工作表的名称与CSV文件之间是否匹配?

[英]how to open excel sheet and CSV file?match between name from excel sheet and the CSV file?

i need code in C# to open my excel sheet which contain list of students names ,and open CSV file contain two columns name of same student in excel sheet, and marks of student ... by click on button i want to match between the names and put in the excel sheet every name with his mark. 我需要C#中的代码来打开包含学生姓名列表的excel工作表,并且打开CSV文件,在excel工作表中包含同一学生的两列名称,以及学生的标记...通过单击按钮,我想在姓名之间进行匹配并在Excel工作表中添加每个带有他标记的名字。 That's all just find names and marks from CSV and put it on next cell of name in excel sheet 只需从CSV查找名称和标记,然后将其放在Excel工作表中的名称的下一个单元格中

Reading from the Excel file: 从Excel文件中读取:

Reading Excel files from C# 从C#读取Excel文件

Reading from the CSV file: 从CSV文件读取:

http://www.switchonthecode.com/tutorials/building-a-simple-csv-parser-in-csharp http://www.switchonthecode.com/tutorials/building-a-simple-csv-parser-in-csharp

(Google for more) (有关Google,更多信息)

You'll want to tweak the final output of this stuff, of course, so they can be easily compared and manipulated against one another. 当然,您需要调整这些内容的最终输出,以便可以轻松地将它们相互比较和操纵。

Writing to the Excel file may be a little trickier. 写入Excel文件可能会有些棘手。 You may end up having to use the COM library for it: 您可能最终不得不使用COM库:

http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ef11a193-54f3-407b-9374-9f5770fd9fd7 http://social.msdn.microsoft.com/Forums/zh-CN/csharpgeneral/thread/ef11a193-54f3-407b-9374-9f5770fd9fd7

But, depending on your needs, you may be able to get away with something simpler: 但是,根据您的需求,您也许可以摆脱一些简单的事情:

http://www.codeproject.com/KB/cs/WriteDataToExcel.aspx http://www.codeproject.com/KB/cs/WriteDataToExcel.aspx

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM