在ASP.NET中使用EXCEL之三 写Excel文件
发布时间:2016-12-05 编辑:jiaochengji.com
教程集为您提供在ASP.NET中使用EXCEL之三 写Excel文件等资源,欢迎您收藏本站,我们将为您提供最新的在ASP.NET中使用EXCEL之三 写Excel文件资源
在按钮的click事件中输入如下代码,即可以实现写入Excel文件。
写Excel文件时,还要把项目文件夹的权限进行设置,对iuser_machine用户有可写的权限。
private void Button1_Click(object sender, System.EventArgs e)
{string filename="";
Excel.ApplicationClass oExcel;
oExcel = new Excel.ApplicationClass();
oExcel.UserControl = false;
Excel.WorkbookClass wb = (Excel.WorkbookClass) oExcel.Workbooks.Add(System.Reflection.Missing.Value);
for(int i = 1;i <= 5; i )
{
oExcel.Cells[i,1]=i.ToString();
oExcel.Cells[i,2]="'第2列";
oExcel.Cells[i,3]="'第3列";
oExcel.Cells[i,4]="'第4列";
}
wb.Saved = true;
filename= Request.PhysicalApplicationPath "test.xls";
oExcel.ActiveWorkbook.SaveCopyAs(filename);
oExcel.Quit();
System.GC.Collect();
Response.Redirect( Request.ApplicationPath "/test.xls");
}
您可能感兴趣的文章:
.net中清除EXCEL进程最有效的方法
php框架laravel excel包使用教程介绍
在ASP.NET中使用EXCEL之三 写Excel文件
PHP导入与导出Excel文件的方法
Farpoint操作excel的用法举例
php读取excel的实例代码
使用VB.NET编写控制excel的程序
使用.NET生成Excel文件
在C#.net 中读取EXCEL文件的数据
PHPExcel导出Excel文件时出现错误的解决办法
[关闭]