Excel.Application oExcel;
Excel.Workbook oBook;
Object oMissing = System.Reflection.Missing.Value;
oExcel = new Excel.Application();
oBook = oExcel.Workbooks.Add(oMissing);
for (int i=1;i <=4;i++)
{
oExcel.Cells[i,1]=i.ToString();
oExcel.Cells[i,2]= "'bbb2 ";
oExcel.Cells[i,3]= "'ccc3 ";
oExcel.Cells[i,4]= "'aaa4 ";
}
oBook.Saved = true;
oExcel.UserControl = false;
string filename = DateTime.Now.Ticks.ToString();
string mm=Server.MapPath( ".")+ "//" + filename + ".xls";//服务器保存地址
oExcel.ActiveWorkbook.SaveCopyAs (mm);
oExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject((object)oExcel);
GC.Collect();
注:转贴来自 http://community.youkuaiyun.com/Expert/topic/4194/4194769.xml?temp=.8031732
Excel.Workbook oBook;
Object oMissing = System.Reflection.Missing.Value;
oExcel = new Excel.Application();
oBook = oExcel.Workbooks.Add(oMissing);
for (int i=1;i <=4;i++)
{
oExcel.Cells[i,1]=i.ToString();
oExcel.Cells[i,2]= "'bbb2 ";
oExcel.Cells[i,3]= "'ccc3 ";
oExcel.Cells[i,4]= "'aaa4 ";
}
oBook.Saved = true;
oExcel.UserControl = false;
string filename = DateTime.Now.Ticks.ToString();
string mm=Server.MapPath( ".")+ "//" + filename + ".xls";//服务器保存地址
oExcel.ActiveWorkbook.SaveCopyAs (mm);
oExcel.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject((object)oExcel);
GC.Collect();
注:转贴来自 http://community.youkuaiyun.com/Expert/topic/4194/4194769.xml?temp=.8031732