本文介绍了动态创建excel并自动下载的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时删除!!

< Microsoft.Office.Interop.Excel.Application xlApp;< br /> 
Microsoft.Office.Interop.Excel.Workbook xlWorkBook;< br />
Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;< br />
object misValue = System.Reflection.Missing.Value;< br />
xlApp = new Microsoft.Office.Interop。 Excel.ApplicationClass();< br />
xlWorkBook = xlApp.Workbooks.Add(misValue);< br />
< br />
xlWorkSheet =(Microsoft.Office .Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);< br />
xlWorkSheet.Cells [1,1] =http://csharp.net-informations.com;< br />
< br />
xlWorkBook.SaveAs(csharp-Excel.xls,Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal,misValue,misValue,misValue,misValue,Microsoft。 Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive,misValue,misValue,misValue,misValue,misValue);< br />
xlWorkBook.Close(true,misValue,misValue);< br />
xlApp.Quit();







这是我的C#按钮代码。我只是想按钮点击自动执行此excel文件下载。此代码仅生成excel文件。以及如何添加下载代码。我不知道。例如,我们在谷歌浏览器中下载任何内容,然后单击项目开始下载。和浏览器下载文件底部显示。怎么做,请帮帮我

谢谢

Advance

解决方案

<Microsoft.Office.Interop.Excel.Application xlApp;<br />
            Microsoft.Office.Interop.Excel.Workbook xlWorkBook;<br />
            Microsoft.Office.Interop.Excel.Worksheet xlWorkSheet;<br />
            object misValue = System.Reflection.Missing.Value;<br />
            xlApp = new Microsoft.Office.Interop.Excel.ApplicationClass();<br />
            xlWorkBook = xlApp.Workbooks.Add(misValue);<br />
<br />
            xlWorkSheet = (Microsoft.Office.Interop.Excel.Worksheet)xlWorkBook.Worksheets.get_Item(1);<br />
            xlWorkSheet.Cells[1, 1] = "http://csharp.net-informations.com";<br />
<br />
            xlWorkBook.SaveAs("csharp-Excel.xls", Microsoft.Office.Interop.Excel.XlFileFormat.xlWorkbookNormal, misValue, misValue, misValue, misValue, Microsoft.Office.Interop.Excel.XlSaveAsAccessMode.xlExclusive, misValue, misValue, misValue, misValue, misValue);<br />
            xlWorkBook.Close(true, misValue, misValue);<br />
            xlApp.Quit();




here is my C# button code. i just want to do this excel file download automatiacally on button click. this code generate excel file only.And how to add download code. i dont know. Example we download anything in google chrome then click the item start download. and bottom of the browser download file show. how to do this,, Please help me
thanks in
Advance

解决方案


这篇关于动态创建excel并自动下载的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

1403页,肝出来的..

09-06 23:52