ReportX - 免费报表控件(ocx)

与AutoHotkey相关的工具

Moderators: tmplinshi, arcticir

Post Reply
tmplinshi
Posts: 1604
Joined: 01 Oct 2013, 14:57

ReportX - 免费报表控件(ocx)

Post by tmplinshi » 20 Aug 2015, 22:26

下载: ReportX_2.7.zip

ReportX.ocx 需要先注册——运行 regsvr32 ReportX.ocx

示例:

Code: Select all

#NoEnv
#SingleInstance force
SetWorkingDir %A_ScriptDir%
SetBatchLines -1

Gui, +LastFound
Gui, Add, ActiveX, w700 h600 vrx, ReportProj1.ReportX
Gui, Add, Button, ys      , 修改单元格
Gui, Add, Button, Disabled, 获取单元格数据
Gui, Add, Button,         , 显示隐藏左侧标杆
Gui, Add, Button,         , 显示隐藏顶部标杆
Gui, Add, Button,         , 保存
Gui, Add, Button,         , 打开文件
Gui, Show
ComObjConnect(rx, reportX_Envents) ; 可以注册事件
Return

Button修改单元格:
	rx.SetCellValue(2, 3, "测试")       ; 设置第2列第3行单元格的文字
	rx.SetCellBackColor(2, 3, 0xEFBC13) ; 设置第2列第3行单元格的背景颜色
	rx.SetCellFontColor(2, 3, 0xFFFFFF) ; 设置第2列第3行单元格的文字颜色
	GuiControl, Enable, 获取单元格数据
Return

Button获取单元格数据:
	MsgBox, % rx.GetCellValue(2, 3)
Return

Button显示隐藏左侧标杆:
	rx.PoleWidth := rx.PoleWidth ? 0 : 43
Return

Button显示隐藏顶部标杆:
	rx.PoleHeight := rx.PoleHeight ? 0 : 17
Return

Button保存:
	If !rxFile {
		FileSelectFile, rxFile, s16, , 保存文件, ReportX文件(*.rpxe)
		If rxFile
			rxFile .= (rxFile ~= "i)\.rpxe$") ? "" : ".rpxe"
	}
	If rxFile {
		rx.SaveReport(rxFile)
		WinSetTitle,,, % rxFile
		MsgBox, 64, 提示, 保存成功!
	}
Return

Button打开文件:
	FileSelectFile, rxFile, 1, , 打开文件, ReportX文件(*.rpxe)
	If rxFile {
		rx.OpenReport(rxFile)
		WinSetTitle,,, % rxFile
	}
Return

GuiDropFiles:
	If (A_GuiEvent ~= "i)\.rpxe") {
		rx.OpenReport(rxFile := A_GuiEvent)
		WinSetTitle,,, % rxFile
	}
Return

GuiClose:
ExitApp

确保已注册ReportX() {
	static _Init := 确保已注册ReportX()
	If !ComObjCreate("ReportProj1.ReportX") {
		If FileExist("ReportX.ocx")
			RunWait, regsvr32 /s ReportX.ocx
		Else {
			MsgBox, 48, 错误, ReportX组件未注册、缺少文件ReportX.ocx!
			ExitApp
		}
	}
	Return True
}

class reportX_Envents {
	OnCellChanged(aCol, aRow, aCellValue) {
		ToolTip, % "aCol: " aCol . "`n"
		         . "aRow: " aRow . "`n"
		         . "aCellValue: " aCellValue
	}
}
2015-08-21_111600.png
更多用法见压缩包中的帮助文件(中文)。

aamii
Posts: 47
Joined: 23 May 2014, 03:50

Re: ReportX - 免费报表控件(ocx)

Post by aamii » 05 Sep 2015, 09:24

先收藏,不知道能不能做个密码记事本啥的

Post Reply

Return to “相关工具”