Excel.Application exl = new Excel.Application();
Excel.Workbooks workbooks = exl.Workbooks;
sfile = Application.StartupPath + "\\DataBase" + "\\"+filename+".xls";
try
{
Excel.Workbook eWorkBook = exl.Workbooks.Open(sfile, true, "Zquick2017");//这里会报错 哎 真的不知道怎么写这个open函数 Excel打开要密码 密码为Zquick2017
}
catch (Exception a)
{
MessageBox.Show(a.Message);
}
Excel.Worksheet eWorkSheet (Excel.Worksheet)exl.Workbooks.Application.ActiveSheet;
for (int i = 0; i < 286; i++)
{
mod1.a0mdb[i]=(int)eWorkSheet.Cells[i+2,1];
//eWorkSheet.Cells(i + 2, 1) = mod1.a0mdb[i];
//eWorkSheet.Cells[i+2,1] = mod1.a0mdb[i];
}
哎 我写的代码错误一大堆 谁能帮我解答一下怎么实现吗 就是把已知的Excel里的数据存入一个数组
上面少了一个等号 看起来怪怪的 就是for循环上一句
Excel.Worksheet eWorkSheet = (Excel.Worksheet)exl.Workbooks.Application.ActiveSheet;
本方案需要引用免费版的spire.xls.dll
using Spire.Xls;