如何在ms excel中显示创建的arraylist? 请指导我..
答案 0 :(得分:1)
添加对Microsoft.Office.Interop.Excel
程序集的引用
然后尝试这个(只是一个想法,而不是完整和完美的代码):
using Excel = Microsoft.Office.Interop.Excel;
Excel.Application excel = new Excel.Application();
Excel.Workbook wb = excel.Workbooks.Open("filename");
Excel.Worksheet sh = wb.Sheets[1]; // or wb.Sheets["name"]
int row = 2;
foreach (string item in array)
{
sh.Cells[row,col].Value2 = item;
row++;
}
wb.Save();
wb.Close();
excel.Quit();