91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 25KB
    文件類型: .cs
    金幣: 1
    下載: 1 次
    發布日期: 2021-06-08
  • 語言: C#
  • 標簽: 生成??excel??

資源簡介

自己用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?????????????{
????????????????for?(int?j?=?1;?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

評論

共有 條評論