privatevoidbutton1_Click(objectsender,System.EventArgse) {//保存为EXCEL文件 if(this.listView1.Items.Count0) { MyRange=MyWorkSheet.get_Range("A2",Missing.Value); object[,]MyData=newObject[this.listView1.Items.Count,3]; foreach(ListViewItemlviinthis.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(ExceptionErr) { MessageBox.Show("调用EXCEL程序时出现错误!"+Err.Message,"信息提示",MessageBoxButtons.OK,MessageBoxIcon.Information); } }
2024/7/7 20:16:32
627KB
EXCEL
1