private void button1_Click(object sender, System.EventArgs e)
{//保存为EXCEL文件
if(this.listView1.Items.Count0)
{
MyRange =MyWorkSheet.get_Range("A2",Missing.Value);
object [,] MyData = new Object[this.listView1.Items.Count,3];
foreach(ListViewItem lvi in this.listView1.Items)
{
MyData[lvi.Index,0] = lvi.Text;
MyData[lvi.Index,1] = lvi.SubItems[1].Text;
MyData[lvi.Index,2] = lvi.SubItems[2].Text;
}
MyRange = MyRange.get_Resize(this.listView1.Items.Count,3);
MyRange.Value2= MyData;
MyRange.EntireColumn.AutoFit();
}
MyExcel= null;
}
catch(Exception Err)
{
MessageBox.Show("调用EXCEL程序时出现错误!"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
}
2010-05-12 00:00:00
627KB
EXCEL
1