从CSV C#的Excel数据导入Excel [英] C# Excel import data from CSV into Excel

查看:243
本文介绍了从CSV C#的Excel数据导入Excel的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何使用C#的CSV文件导入Excel中的数据?其实,我想实现的是类似于我们在Excel中做的,你去数据标签,然后选择从文本选项,然后使用正文对列选项,并选择CSV和它的魔力,和所有的东西。我想自动化。

How do I import data in Excel from a CSV file using C#? Actually, what I want to achieve is similar to what we do in Excel, you go to the Data tab and then select From Text option and then use the Text to columns option and select CSV and it does the magic, and all that stuff. I want to automate it.

如果你能拦住了我在正确的方向,我会很感激的。

If you could head me in the right direction, I'll really appreciate that.

编辑:我想我没有解释好。我想要做的是一样的东西。

I guess I didn't explained well. What I want to do is something like

Excel.Application excelApp;
Excel.Workbook excelWorkbook;

// open excel
excelApp = new Excel.Application();

// something like
excelWorkbook.ImportFromTextFile(); // is what I need



我想这些数据导入到Excel中,而不是我自己的应用程序。据我所知,我不认为我会解析CSV自己,然后在Excel中插入。 Excel中确实为我们。我只需要知道如何自动执行该过程。

I want to import that data into Excel, not my own application. As far as I know, I don't think I would have to parse the CSV myself and then insert them in Excel. Excel does that for us. I simply need to know how to automate that process.

推荐答案

您可以打开Excel,开始录制宏,做你想做的,然后看看录制的内容的宏。这应该告诉你哪些对象使用和如何使用它们。

You could open Excel, start recording a macro, do what you want, then see what the macro recorded. That should tell you what objects to use and how to use them.

这篇关于从CSV C#的Excel数据导入Excel的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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