(1)在“解决方案”处,点“引用”,再“添加引用”,后选“com”,再点击”microsoft excel”,并确认。
(2)引用命名空间,using Excel = Microsoft.Office.Interop.Excel;//添加命名空间
(3)所有代码如下,
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Windows;
using Excel = Microsoft.Office.Interop.Excel;//添加命名空间
namespace 将listview_转换为_excel
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void label1_Click(object sender, EventArgs e)
{
}
private void button2_Click(object sender, EventArgs e)
{
ListViewItem mylistView = listView1.Items.Add(