日期:2014-05-17 浏览次数:21080 次
using System;
using System.Windows.Forms;
using Excel=Microsoft.Office.Interop.Excel;
//首先要在引用里添加Microsoft.Office.Interop.Excel
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Excel.Application XlsApp = new Excel.ApplicationClass();
Excel.Workbook Wb = XlsApp.Workbooks.Add();
Excel.Worksheet Sh = (Excel.Worksheet)Wb.Sheets[1];
Excel.Range Rng = Sh.get_Range("A1:H10");
Rng.Value = 1;
object Arr = Rng.Value; //可以区域赋值到arr,为object类型(list?)
XlsApp.Visible = true;
}
}
}
Rng.Cells.Rows.Count
Rng.Cells.Columns.Count