首页 > 其他分享 >delphi操作excell文件实现学生均衡分班

delphi操作excell文件实现学生均衡分班

时间:2024-08-29 15:53:15浏览次数:4  
标签:24 end Color delphi Height excell Font 分班 Left

unit Unit1; interface uses Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls,System.Win.ComObj; type TForm1 = class(TForm) Button1: TButton; Label19: TLabel; Label20: TLabel; Label21: TLabel; Edit6: TEdit; Edit7: TEdit; Edit1: TEdit; Edit2: TEdit; Label1: TLabel; Label2: TLabel; Label3: TLabel; Edit3: TEdit; Label4: TLabel; Edit4: TEdit; Label5: TLabel; Edit5: TEdit; procedure Button1Click(Sender: TObject); procedure FormShow(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var ExcelApp: Variant; FSheet: Variant; sheetno:Integer; rowno:integer; sheetname1,edit1text:string; gezhi,shijian,riqi:Integer; kaishibanji,banji,banjishu,jieguolineno:Integer; banjistr:string; fangan:Integer; begin//0 ExcelApp:= GetActiveOleObject('Excel.Application'); ExcelApp.visible:=true; FSheet :=ExcelApp.ActiveWorkbook.Activesheet; kaishibanji:=StrToInt(Edit4.text); //第个人分配到的班级数 banji:=StrToInt(Edit2.text); //第个人分配到的班级数 banjishu:=StrToInt(Edit1.text) ; //总的班级数 jieguolineno:=StrToInt(Edit3.text) ; //结果放在第几列 fangan:=1; //方案开关 for rowno := StrToInt(Edit6.Text) to StrToInt(Edit7.Text) do begin Sleep(1000) ; FSheet.Cells[rowno,jieguolineno].Value :=banji; banjistr:=IntToStr(banji); FSheet.Cells[rowno,jieguolineno+1].Value :=Edit5.Text+'('+banjistr+')班'; case fangan of 1:begin //方案1如果班级小于最后一个班级,班级数加1,如果班级等于最大班级,班级不变,方案变成2号方案 if banji<kaishibanji+banjishu-1 then="" banji:="banji+1" else="" if="" banji="kaishibanji+banjishu-1" fangan:="2;" end;="" 2:begin="" 方案2如果班级大于开始班级,班级数减1,如果班级等于最小班级,班级不变,方案变成1号方案="">kaishibanji then banji:=banji-1 else if banji=kaishibanji then fangan:=1; end; end; end; end; procedure TForm1.FormShow(Sender: TObject); begin Form1.FormStyle:=fsStayOnTop; form1.Left:=1420; form1.top:=600; end; object Form1: TForm1 Left = 0 Top = 0 Caption = #22343#34913#20998#29677 ClientHeight = 671 ClientWidth = 960 Color = clBtnFace Font.Charset = DEFAULT_CHARSET Font.Color = clWindowText Font.Height = -12 Font.Name = 'Segoe UI' Font.Style = [] OnShow = FormShow TextHeight = 15 object Label19: TLabel Left = 35 Top = 144 Width = 50 Height = 24 Caption = #20174#31532 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Label20: TLabel Left = 169 Top = 144 Width = 50 Height = 24 Caption = #21040#31532 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Label21: TLabel Left = 283 Top = 144 Width = 25 Height = 24 Caption = #34892 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Label1: TLabel Left = 8 Top = 208 Width = 225 Height = 24 Caption = #31532#19968#20010#21516#23398#30340#29677#32423#21495 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Label2: TLabel Left = 228 Top = 83 Width = 100 Height = 24 Caption = #29677#32423#24635#25968 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Label3: TLabel Left = 8 Top = 264 Width = 250 Height = 24 Caption = #20998#29677#32467#26524#20445#23384#22312#31532#20960#21015 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Label4: TLabel Left = 8 Top = 83 Width = 100 Height = 24 Caption = #24320#22987#29677#32423 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Label5: TLabel Left = 8 Top = 27 Width = 75 Height = 24 Caption = #24180#32423#65306 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False end object Button1: TButton Left = 18 Top = 326 Width = 290 Height = 67 Caption = #24320#22987#20998#29677 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False TabOrder = 0 OnClick = Button1Click end object Edit6: TEdit Left = 103 Top = 141 Width = 60 Height = 32 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ImeName = #20013#25991'('#31616#20307') - '#19975#33021#20116#31508#36755#20837#27861 ParentFont = False TabOrder = 1 Text = '3' end object Edit7: TEdit Left = 228 Top = 141 Width = 49 Height = 32 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ImeName = #20013#25991'('#31616#20307') - '#19975#33021#20116#31508#36755#20837#27861 ParentFont = False TabOrder = 2 Text = '13' end object Edit1: TEdit Left = 346 Top = 80 Width = 91 Height = 32 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False TabOrder = 3 Text = '5' end object Edit2: TEdit Left = 251 Top = 205 Width = 102 Height = 32 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False TabOrder = 4 end object Edit3: TEdit Left = 264 Top = 261 Width = 101 Height = 32 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False TabOrder = 5 end object Edit4: TEdit Left = 124 Top = 80 Width = 63 Height = 32 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False TabOrder = 6 Text = '1' end object Edit5: TEdit Left = 124 Top = 24 Width = 63 Height = 32 Font.Charset = ANSI_CHARSET Font.Color = clWindowText Font.Height = -24 Font.Name = #26032#23435#20307 Font.Style = [fsBold] ParentFont = False TabOrder = 7 Text = #19968 end end

标签:24,end,Color,delphi,Height,excell,Font,分班,Left
From: https://www.cnblogs.com/yehuiyan/p/18386858

相关文章

  • 达梦数据库在Delphi10.3上的安装与连接
          ......
  • delphi初级教程之delphi断点调试一
    所谓断点,就是在程序代码的某一行上设置一个标记,程序执行到这里将暂停,由调试器接管对程序的控制。使用断点与使用【RuntoCursor】命令有些相似,都是执行到某一行后暂停。不同的是,程序中可以设置多个断点并且能够给断点设置条件。断点通常设置在有疑点的区域。在遇到断点之前,程序......
  • delphi debug 输出
    在Delphi中,你可以使用OutputDebugString函数将调试信息发送到调试器。这个函数是WindowsAPI的一部分,可以在任何使用WindowsAPI的Delphi应用程序中使用。以下是一个简单的例子,展示如何使用OutputDebugString来输出调试信息:usesWindows;procedureTForm1.Button1Click(Se......
  • 在Delphi中:如何在调试时跳过部分代码?
    在Delphi中调试时,我经常无意地进入我不感兴趣的代码。让我们首先说,我知道您可以使用F8,并且可以使用f4运行到特定的行。示例:functionTMyClass.DoStuff():Integer;begin//dosomestuffbla();end;procedureTMyClass.Foo()beginifDoStuff()=0then//pressF7......
  • delphi dxCameraControl控件(拍照)
    拍照演示DevExpressVCL组件之一 TdxCameraControlObjectHierarchy  Properties  Methods  Events 一个摄像头控件Unit dxCameraControl Syntax TdxCameraControl= class(TdxCustomCameraControl) Descrition 该控件允许您捕捉视频或图像从内......
  • delphi 里的 in 集合 语法
    在Delphi中,In关键字用于检查一个元素是否存在于一个集合中。这在处理枚举类型或集合类型时非常有用。下面是一个使用In关键字的基本示例,演示如何检查某个值是否属于一个枚举或集合。首先,假设我们有一个枚举类型:typeTDays=(Monday,Tuesday,Wednesday,Thursday,Frid......
  • 初学 Delphi 嵌入汇编[1] - 汇编语言与机器语言
    非科班出身,现在才接触汇编,惭愧呀,好好学!主选课本是清华大学王爽老师的《汇编语言》.推荐 王爽老师的汇编网汇编语言之前是机器语言.机器语言是机器指令的集合,机器指令是一系列二进制数字,计算机将之转换为一系列高低电平,而实现运算.在PC机上运行机器指令的是CPU;......
  • 初学 Delphi 嵌入汇编[2] - 汇编语言关键字
    汇编语言不区分大小写.关键字用途AH AL AND AX BH BL BP BX BYTE CH CL CS CX DH DI DL DS DWORD DX EAX EBP EBX ECX EDI EDX EIP ES ESI ESP FS ......
  • 初学 Delphi 嵌入汇编[3] - 第一个 Delphi 与汇编的例子
    前面知道了一个汇编的赋值指令(MOV),再了解一个加法指令(ADD),就可以做个例子了.譬如:ADDAX,BX;这相当于Delphi中的AX:=AX+BX;另外提前来个列表-Delphi可以用汇编管理以下寄存器:32位寄存器:EAXEBXECXEDXESPEBPESIEDI16位寄存器:AXBXCXDXSPBPSID......
  • delphi webbrowser屏蔽右键菜单 防止右键 防止ctrl N
    本文介绍了如何在Delphi中通过事件处理和消息过滤,阻止WebBrowser控件中的右键菜单以及防止用户使用Ctrl+N快捷键。通过`ProcessMsg`和`ApplicationEvents1Message`等方法实现对浏览器行为的控制。{关键字=webbrowser屏蔽右键菜单防止右键防止ctrlN采集软件=MKM-我的知识管理......