logo资料库

c#获取excel中鼠标所选区域的内容.doc

第1页 / 共1页
资料共1页,全文预览结束
using Excel=Microsoft.Office.Interop.Excel; %%%增加COM组件中的Excel引用 Excel.Application Excel.Worksheet mysht;%%%%打开工作的worksheet app = (Excel.Application)System.Runtime.InteropServices.%%% app;%%%打开excel应用 Marshal.GetActiveObject("Excel.Application");%%%excel 应用赋值 mysht = (Excel.Worksheet)app.ActiveSheet;%%工作worksheet赋值 Excel.Range range = mysht.Application.Selection;%%%获取鼠标所选内容 List exceldata = new List();%%%新建一个字符列表 foreach(Excel.Range rg in range)%%%%将鼠标所选内容加入列表中。循环 if(rg.Text!="") exceldata.Add(rg.Text);
分享到:
收藏