sql导出excel 如何提供客户端下载

来源:百度知道 编辑:UC知道 时间:2024/09/23 12:03:09
用的是excel.Application哦!

C#.NET实现EXCEL操作类 - .NET读取和设置EXCEL电子表格单元的参考代码

using System;
using Excel;

namespace ExcelExample
{
/// <summary>
/// Summary description for Class1.
/// </summary>
class ExcelClass
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
static void Main(string[] args)
{
Excel.Application excelApp = new Excel.ApplicationClass(); // Creates a new Excel Application
excelApp.Visible = false; // Makes Excel visible to the user.

// The following line adds a new workbook
Excel.Workbook newWorkbook = excelApp.Workbooks.Add(XlWBATemplate.xlWBATWorksheet);

// The following code opens an existing workbook
string workbookPath = "c:/SomeWorkBook.xls"; // Add your own path here
Excel.Workbook excelWorkbook = excelApp.Workbooks.Open(workbookPath, 0,
false, 5, "", &