将datagridview导出到Excel文档 [英] export datagridview to Excel Document

查看:81
本文介绍了将datagridview导出到Excel文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我做了一个搜索并确实发现了这个帖子但是我无法让它工作但是我想知道是否有人有解决方案将datagridview列和数据导出到excel电子表格?

I did a search and did find a post on this however I couldn't get it to work but I was wondering if anyone had a solution to exporting datagridview columns and data to a excel spreadsheet?

推荐答案

一个简单的解决方案是使用数据创建一个csv文件。

One simple solution is to create a csv file with the data.

你只需要在你的上面写一个for循环datasource,以csv格式转储文件中的数据,然后你可以在文件上dblclick以在excel中打开它。

You just have to write a for loop on your datasource, dump the data in the file in the csv format, and then you can dblclick on the file to open it in excel.

Charles

这篇关于将datagridview导出到Excel文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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