Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/309.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Excel自动化:读取csv文件并更新Excel文件_C#_Excel_Csv - Fatal编程技术网

C# Excel自动化:读取csv文件并更新Excel文件

C# Excel自动化:读取csv文件并更新Excel文件,c#,excel,csv,C#,Excel,Csv,我有一个自动测试,它生成一个包含两列数据的csv。 我有一个excel文件,用于收集工作表中所有运行的结果 我想在每次测试运行后完全自动化更新Excel文件的过程 这可能就是我想做的: 1. Read the two columns from the CSV file 2. Paste the two columns in a worksheet in the excel file, in the first empty column to the right of the existi

我有一个自动测试,它生成一个包含两列数据的csv。 我有一个excel文件,用于收集工作表中所有运行的结果

我想在每次测试运行后完全自动化更新Excel文件的过程

这可能就是我想做的:

1. Read the two columns from the CSV file
2. Paste the two columns in a worksheet in the excel file, in the first 
   empty column to the right of the existing block of columns.
3. Save the Excel file
编辑:

现在我知道我可以使用宏执行步骤1-3。
我只需要弄清楚如何启动宏。

您可以使用一个数据提供程序OleDb提供程序读取csv并写入Excel工作表。这是一个关于如何写入Excel的示例,也是一个关于如何读取csv的示例。

一旦写入宏,它应该位于Excel中该Excel文档的宏列表中。可以将宏绑定到击键(如Alt-i、Alt等),以便在按下该组合键时运行宏


我在两个类似的项目上做过这项工作,我需要从其他来源导入CSV文件,并将数据放入Excel工作表中。

我的问题如何可能与您建议的链接重复?但我仍然希望自动调用宏,而无需我击键。