C#将dataGridView中显示的数据导出到Excel(超实用版)

2020-12-13 14:47

阅读:496

标签:datagridview   blog   io   os   ar   for   数据   on   2014   

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Interop;
using Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
using Excel = Microsoft.Office.Interop.Excel; 

public class ExprotToExcel
{ 
    public void  DataToExcel(DataGridView dgv,ToolStripProgressBar tempProgressBar,ToolStripStatusLabel toolstrip)
    {
        if (dgv.Rows.Count == 0)
        {
            MessageBox.Show("无数据"); return;
        }
        MessageBox.Show("开始生成要导出的数据", "导出提示", MessageBoxButtons.OK, MessageBoxIcon.Information);
        Excel.Application excel = new Excel.Application();
        excel.Application.Workbooks.Add(true);
        excel.Visible = false;   
        for (int i = 0; i 

C#将dataGridView中显示的数据导出到Excel(超实用版)

标签:datagridview   blog   io   os   ar   for   数据   on   2014   

原文地址:http://blog.csdn.net/lucky51222/article/details/40663015


评论


亲,登录后才可以留言!