资源简介
自己用c#编写的财务管理系统中生成资产负债表(excel)的类,形成表的样式已排好,只需根据需要添加数据库的数据即可。
代码片段和文件信息
using System;
using System.Collections.Generic;
using System.Text;
namespace ClassLibrary1
{
public class Class1
{
public void Export(string btitle)
{
string rq = DateTime.Now.Year.ToString() + “年“ + DateTime.Now.Month.ToString() + “月“ + DateTime.Now.Day.ToString() + “日“;
//建立Excel对象
Excel.Application excel = new Excel.Application();
excel.Application.Workbooks.Add(true);
excel.Visible = true;
Excel.Range range = excel.get_Range(excel.Cells[1 1] excel.Cells[1 8]);//选中范围第一行的1到7列的单元格
range.MergeCells = true;//合并上述范围的单元格
//excel.get_Range(excel.Cells[1 1] excel.Cells[1 dgv.ColumnCount]).Cells.Font.Name = “宋体“;
excel.ActiveCell.Font.Name = “宋体“;
excel.ActiveCell.Font.Bold = true;
excel.ActiveCell.FormulaR1C1 = btitle;//合并的单元格为当前活动单元格,设置其内容为表头
excel.ActiveCell.HorizontalAlignment = Excel.XlHAlign.xlHAlignCenter;//设置其内容在合并的大单原格中居中
excel.ActiveCell.Font.Size = “15“;
//excel.get_Range(excel.Cells[1 1] excel.Cells[1 3]).Cells.Font.Size = “15“;
//excel.Cells.EntireColumn.AutoFit();
excel.Caption = “记账凭证导出数据“;
for (int i = 3; i < 39; i++)
{
for (int j = 1; j < 9; j++)
{
excel.get_Range(excel.Cells[i - 1 j] excel.Cells[i - 1 j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeBottom].ColorIndex = 28;//设置选定单元格的下边框颜色
excel.get_Range(excel.Cells[i - 1 j] excel.Cells[i - 1 j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeBottom].Linestyle = Excel.XlLinestyle.xlContinuous;//
excel.get_Range(excel.Cells[i - 1 j] excel.Cells[i - 1 j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeBottom].Weight = Excel.XlBorderWeight.xlThin;//
excel.get_Range(excel.Cells[i j] excel.Cells[i j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeLeft].ColorIndex = 38;//设置选定单元格的下边框颜色
excel.get_Range(excel.Cells[i j] excel.Cells[i j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeLeft].Linestyle = Excel.XlLinestyle.xlContinuous;//
excel.get_Range(excel.Cells[i j] excel.Cells[i j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeLeft].Weight = Excel.XlBorderWeight.xlThin;//
excel.get_Range(excel.Cells[i j] excel.Cells[i j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeRight].ColorIndex = 38;//设置选定单元格的下边框颜色
excel.get_Range(excel.Cells[i j] excel.Cells[i j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeRight].Linestyle = Excel.XlLinestyle.xlContinuous;//
excel.get_Range(excel.Cells[i j] excel.Cells[i j]).Cells.Borders[Excel.XlBordersIndex.xlEdgeRight].Weight = Excel.XlBorderWeight.xlThin;//
}
}
//excel.get_Range(excel.Cells[3 1] excel.Cells[40 3]).Cells.B
相关资源
- C# TIP文件生成和拆解
- MVC model层代码生成器 C#
- C#左侧导航菜单(动态生成)
- C# winform实现表数据导出到Excel表格
- ExcelHelper C#操作Excel的好几种方法
- C#代码生成器(生成MVC三层代码)
- 汉字二维码生成及解码
- c#生成excel图表
- C#代码生成工具
- C#动态生成voronoi图
- Winform中嵌入excel
- .net core 动态生成 Word文档(word Expor
- unity读取Excel
- C# 读写excel word(不用安装office)
- 读取mdb输出到Excel
- 数据表转实体源码(实体类生成器)
- C# 条码、二维码生成器
- 各种方式对excel导出导入
- excel转化成datatable 并加载到datagridvi
- 读取Excel表格内容到treeview
- ADO.NET操作EXCEL
- C# 批量生成二维码工具
- excel导入 导出分析源码
-
C# 读写xm
l文件(xm l文件生成按钮 - c# 生成doc文档(附自定义表格)
- 二维码 生成,解析
- AE生成DEM
- In-Sight_Key_Generator
- 根据输入的随机码,生成校验码
- 二维码生成解析工具源码
评论
共有 条评论