当前位置:首页教育技巧excel技巧excel表格单元

数据库excel表格怎么

2024-07-05 10:16:53


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

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, "", "", false, Excel.XlPlatform.xlWindows, "", true,

false, 0, true, false, false);

// The following gets the Worksheets collection

Excel.Sheets excelSheets = excelWorkbook.Worksheets;

// The following gets Sheet1 for editing

string currentSheet = "Sheet1";

Excel.Worksheet excelWorksheet = (Excel.Worksheet)excelSheets.get_Item(currentSheet);

// The following gets cell A1 for editing

Excel.Range excelCell = (Excel.Range)excelWorksheet.get_Range("A1", "A1");

// The following sets cell A1's value to "Hi There"

excelCell.Value2 = "Hi There";

}

}

相关信息


电脑版

【免责声明】本站信息来自网友投稿及网络整理,内容仅供参考,如果有错误请反馈给我们及时更正,对文中内容的真实性和完整性本站不提供任何保证,不承但任何责任。
版权所有:学窍知识网 Copyright © 2011-2024 www.at317.com All Rights Reserved .