Common/DataToExcel.cs
(开头部分) 1KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Diagnostics;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Excel;
using Microsoft.Win32;
using System.IO;
using System.Reflection;
namespace Common
{
/// <summary>
/// 操作EXCEL导出数据报表的类
///
/// </summary>
public class DataToExcel
{
public DataToExcel()
{
}
#region 操作EXCEL的一个类(需要Excel.dll支持)
private int titleColorindex = 15;
/// <summary>
/// 标题背景色
/// </summary>
public int TitleColorIndex
{
set { titleColorindex = value; }
get { return titleColorindex; }
}
private DateTime beforeTime; //Excel启动之前时间
private DateTime afterTime; //Excel启动之后时间
#region 创建一个Excel示例
/// <summary>
/// 创建一个Excel示例
/// </summary>
public void CreateExcel()
{
Excel.Application excel = new Excel.Application();
excel.Application.Workbooks.Add(true);
excel.Cells[1, 1] = "第1行第1列";
excel.Cells[1, 2] = "第1行第2列";
excel.Cells[2, 1] = "第2行第1列";
excel.Cells[2, 2] = "第2行第2列";
Excel.Workbook book = excel.Application.Workbooks.Add(System.Reflection.Missing.Value);//引用
Excel.Worksheet sheet = (Excel.Worksheet)book.Worksheets["Sheet1"];//选中
sheet.Cells[1, 3] = "Mytest";//左上角第一格的坐标是[1,1]
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
