求一段用EXCEL.DLL将数据导出到EXCEL的代码!!!

xinxincao 2003-10-14 05:00:03
excelapp.Quit();
excelapp = null;
GC.Collect();

我用这种方法总是关不掉EXCEL.EXE进程,生成的文件也无法点开。
...全文
32 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
xinxincao 2003-10-18
  • 打赏
  • 举报
回复
to zhyx21century(不想去编程)
用OWC那个库生成的东西不是真正的电子表格,在导入时,不能被识别;

to dongbeiren() ( )
现在的问题是,在任务管理器里手工都杀不掉这个进程,我试了你的代码,也行不通


继续问!!!
zhyx21century 2003-10-16
  • 打赏
  • 举报
回复
use owc
SpreadsheetClass xlsheet = new SpreadsheetClass();
cnn.Open();
SqlDataReader reader = this.sql.ExecuteReader();
int numbercols = reader.FieldCount;
int row=1;
while (reader.Read())
{
for (int i=0;i<numbercols;i++)
{
xlsheet.ActiveSheet.Cells[row,i+1] = reader.GetValue(i).ToString();
}
row++;
}
reader.Close();
cnn.Close();
xlsheet.ActiveSheet.Export(Server.MapPath(".")+"\\"+this.xlfile.Text,OWC.SheetExportActionEnum.ssExportActionNone);
lucidaxy 2003-10-16
  • 打赏
  • 举报
回复
有没有更好的方法?不可以主动释放吗?
dongbeiren 2003-10-16
  • 打赏
  • 举报
回复
Dim process As System.Diagnostics.Process
For Each process In System.Diagnostics.Process.GetProcesses
If process.ProcessName = "EXCEL" Then
process.Kill()
End If
Next
xinxincao 2003-10-16
  • 打赏
  • 举报
回复
怎么问了几天也没人帮帮忙!!!
xinxincao 2003-10-15
  • 打赏
  • 举报
回复
请大家关注一下!
xinxincao 2003-10-14
  • 打赏
  • 举报
回复
Object Nothing=System.Reflection.Missing.Value;
Excel.Application excelapp = new Excel.ApplicationClass();
Excel.Workbook oBook = excelapp.Workbooks.Add(true);
Excel.Worksheet oSheet = (Excel.Worksheet)oBook.Worksheets.Add( Nothing, Nothing, Nothing, Nothing);
oSheet.Cells[1,1] = "sss";
oBook.SaveAs(@"E:\\test.xls",Nothing,Nothing,Nothing,Nothing,Nothing,Excel.XlSaveAsAccessMode.xlNoChange
,Nothing,Nothing,Nothing,Nothing);
oBook.Close(Nothing,Nothing,Nothing);
excelapp.Quit();
oSheet = null;
oBook = null;
excelapp = null;

执行到oBook.SaveAs一句就执行不下去了,???????
孟子E章 2003-10-14
  • 打赏
  • 举报
回复
Process.Kill()
acewang 2003-10-14
  • 打赏
  • 举报
回复
http://www.aspxcn.com/dotnetarticle/html/97.html

62,046

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧