|
发表于 2009-6-29 13:44:05
|
显示全部楼层
弄个简体版
[AU3] excel 相关操作
;====================================================================
;档案相关
;====================================================================
; 开一个新的 excel
_ExcelBookNew($fVisible = 1)
; 开启一个存在的档案
_ExcelBookOpen($sFilePath, $fVisible = 1, $fReadOnly = False)
; 开启一个 文字型的 象csv 那种的 $sDelimiter 分隔符号 预设是逗点
_ExcelBookOpenTxt($sFilePath, $sDelimiter = ",", $iStartRow = 1, $iDataType = 1, $iTextQualifier = 1, $fConsecDelim = False, $fVisible = 1)
;存档
_ExcelBookSave($oExcel, $fAlerts = 0)
; 另存新档
_ExcelBookSaveAs($oExcel, $sFilePath, $sType = "xls", $fAlerts = 0, $fOverWrite = 0)
#CS
If $sType = "xls" Then $sType = $xlNormal
If $sType = "csv" Then $sType = $xlCSVMSDOS
If $sType = "txt" Then $sType = $xlTextWindows
If $sType = "template" Then $sType = $xlTemplate
If $sType = "html" Then $sType = $xlHtml
#CE
;关闭
_ExcelBookClose($oExcel, $fSave = 1, $fAlerts = 0)
; 没用过 看的见看不见
_ExcelShow($oExcel)
_ExcelHide($oExcel)
;====================================================================
;重头戏
;====================================================================
; 读写 资料
_ExcelWriteCell($oExcel, $sValue, $sRangeOrRow, $iColumn = 1)
_ExcelReadCell($oExcel, $sRangeOrRow, $iColumn = 1)
;写入公式 没用过
_ExcelWriteFormula($oExcel, $sFormula, $sRangeOrRow, $iColumn = 1)
; 读写资料 ARRAY
_ExcelWriteArray($oExcel, $iStartRow, $iStartColumn, $aArray, $iDirection = 0, $iIndexBase = 0)
_ExcelReadArray($oExcel, $iStartRow, $iStartColumn, $iNumCells, $iDirection = 0, $iIndexBase = 0)
;覆制 贴上
_ExcelCopy($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1)
_ExcelPaste($oExcel, $sRangeOrRow, $iColumn = 1)
; 插入 没用过
_ExcelInsert($oExcel, $sRangeOrRow, $iColumn = 1, $iShiftDirection = -4121)
; 整列操作 删列 新增列 ==
_ExcelRowDelete($oExcel, $iRow, $iNumRows = 1)
_ExcelRowInsert($oExcel, $iRow, $iNumRows = 1)
; 整栏操作 删栏 新增栏 ||
_ExcelColumnDelete($oExcel, $iColumn, $iNumCols = 1)
_ExcelColumnInsert($oExcel, $iColumn, $iNumCols = 1)
;====================================================================
;;其他功能
;====================================================================
; 搜寻 很好用 找字串 $sFindWhat
_ExcelFindInRange($oExcel, $sFindWhat, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDataType = 0, $iWholeOrPart = 2, $fMatchCase = False, $fMatchFormat = False)
;范围内取代
_ExcelReplaceInRange($oExcel, $sFindWhat, $sReplaceWith, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iWholeOrPart = 2, $fMatchCase = False, $fMatchFormat = False, $fReplaceFormat = False)
;====================================================================
; 格式相关
;====================================================================
;set 为设定 get 为取得
; 字型相关
; 设定字型 粗体 斜体 底线
_ExcelFontSetProperties($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $fBold = False, $fItalic = False, $fUnderline = False)
;设定字型 字体
_ExcelFontSet($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $sFontName = "Arial")
_ExcelFontGet($oExcel, $sRangeOrRow, $iColumn = 1)
;字体大小
_ExcelFontSetSize($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iFontSize = 10)
_ExcelFontGetSize($oExcel, $sRangeOrRow, $iColumn = 1)
;字体颜色
_ExcelFontSetColor($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iColorIndex = 1, $hColor = 0x000000)
_ExcelFontGetColor($oExcel, $sRangeOrRow, $iColumn = 1)
;格子的颜色
_ExcelCellColorSet($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iColorIndex = 1, $hColor = 0x000000)
_ExcelCellColorGet($oExcel, $sRangeOrRow, $iColumn = 1)
;宽度
_ExcelColWidthSet($oExcel, $vColumn, $vWidth)
_ExcelColWidthGet($oExcel, $vColumn)
;高度
_ExcelRowHeightSet($oExcel, $iRow, $vHeight)
_ExcelRowHeightGet($oExcel, $iRow)
;??
_ExcelCellFormat($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $fWrapText = False, $iOrientation = 0, $fAddIndent = False, $iIndentLevel = 0, $fShrinkToFit = False)
;====================================================================
; 试算表的动作
;====================================================================
;目标指向 该页
_ExcelSheetActivate($oExcel, $vSheet)
;移动
_ExcelSheetMove($oExcel, $vMoveSheet, $vRelativeSheet = 1, $fBefore = True)
;新增
_ExcelSheetAddNew($oExcel, $sName = "")
;取得目前的名称
_ExcelSheetNameGet($oExcel)
; 改名称 or 设定名称
_ExcelSheetNameSet($oExcel, $sSheetName)
;删除页
_ExcelSheetDelete($oExcel, $vSheet, $fAlerts = False)
; 取回页 列表 array
_ExcelSheetList($oExcel)
;====================================================================
;比较少用到的函数
;====================================================================
;排序 没用过
_ExcelSort($oExcel, $sKey, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDirection = 2)
_ExcelSortExtended($oExcel, $sKey, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $iDirection = 2, $iHeader = 0, $fMatchCase = False, $iOrientation = 2, $iDataOption = 0)
; 注解
_ExcelCommentAdd($oExcel, $sComment, $sRangeOrRow, $iColumn = 1, $fVisible = 0)
_ExcelCommentDelete($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1)
_ExcelCommentShow($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $fVisible = False)
_ExcelCommentRead($oExcel, $sRangeOrRow, $iColumn = 1)
;切开
_ExcelSplitWindow($oExcel, $iSplitRow, $iSplitColumn)
;不晓得怎么用的
_ExcelNumberFormat($oExcel, $sFormat, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1)
_ExcelPictureInsert($oExcel, $sFilePath, $iLeft, $iTop, $iWidth, $iHeight, $fLinkToFile = False, $fSaveWithDoc = False)
_ExcelPictureAdjust($oPicture, $iHorizontal, $iVertical, $iRotation = 0)
_ExcelPictureScale($oPicture, $nScaleWidth = 1, $nScaleHeight = 1, $fScaleOrigWidth = True, $fScaleOrigHeight = True, $iScaleFrom = 0)
_ExcelHyperlinkInsert($oExcel, $sLinkText, $sAddress, $sScreenTip, $sRangeOrRow, $iColumn = 1)
_ExcelCellMerge($oExcel, $fDoMerge, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1)
_ExcelSheetUsedRangeGet($oExcel, $vSheet)
_ExcelHorizontalAlignSet($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $sHorizAlign = "left")
_ExcelVerticalAlignSet($oExcel, $sRangeOrRowStart, $iColStart = 1, $iRowEnd = 1, $iColEnd = 1, $sVertAlign = "bottom") |
|