Gridview查询得到数据后,根据日期在服务器端生成了相应的EXCEL文档,我想生成文档后直接就打该文档,应如何写代码呢。
解决方案 »
- picturebox不能显示滚动条,求高手指教!
- 关于Windows服务程序远程连接sqlserver数据库的问题
- 晕了,关于事件类的参数
- 怎样让web服务器发送数据包
- 怎样取得类或接口的GUID?
- 请各位大侠们指教,怎样用C#代码来设置IIS的默认FTP站点允许匿名连接???急啊!!!
- this["name"]是叫"索引"吗?
- 请教下打印里e.Graphics.DrawString的问题
- DataView问题求助!!
- WinForm控件布局问题,我在Windows2000 Server上布局好的控件到了Windows.NET 2003 Server上控件的位置和大小改变了,反过来在Windows.NET
- [散分][分享]写了个C#的排列类
- 求C# WINMobile 下实现FTP的上传下载!!!
Excel.Application app = new Application();
Excel._Workbook book;
Excel._Worksheet sheet;
book = (Excel._Workbook)app.Workbooks.Open(strPath, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,
Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value); book.Save();
book.Close(null, null, null);
app.Workbooks.Close();
app.Quit();
System.Runtime.InteropServices.Marshal.ReleaseComObject(app);
System.Runtime.InteropServices.Marshal.ReleaseComObject(book);
System.Runtime.InteropServices.Marshal.ReleaseComObject(sheet);
sheet = null;
book = null;
app = null;
输出实现下载
或gridview导出EXCEL
ExcelFile excelFile = new ExcelFile();
ExcelWorksheet sheet = excelFile.Worksheets.Add("报表");
int columns = GridView1.Columns.Count;
int rows = GridView1.Rows.Count; sheet.Cells[1, 0].Value = GridView1.Rows[0].Cells[0].Text;
string temp_path = Server.MapPath("xls_files");
string tick = DateTime.Now.Ticks.ToString();
string save_path = temp_path + "\\"+ tick + ".xls";
excelFile.SaveXls(save_path);
//上述代码已经在服务器上生成一个EXCEL文档,我想在生成EXCEL文档后能在客户端直接弹出一个打开,保存该文档的对话框,下载到客户端,不知怎么实现。
因为excel只能保存65K多条。
所以我一般都保存为csv格式的,我处理的数据随便一搞就几十万