Skip to main content

Automatic-Filling-Area

Command Description

Automatically filling in the cell of the designated area

Command Prototype

Excel.AutoFill(objExcelWorkBook,sheet,srcRange,distRange)

Parameter Description

ParameterRequiredTypeDefaultDescription
objExcelWorkBookTrueexpressionobjExcelWorkBookExcel workbook object (workbook opened with "Open Excel" command (Excel.OpenExcel) or the workbook object returned by the command "Bind Excel" (Excel.BindBook))
sheetTruestring"Sheet1"The string means sheet name. The number means sheet order(starting from 0)
srcRangeTruestring"A1:A2"The specified area. Can input cell names (case insensitive) such as "A1: B2" and a two-dimensional array such as [[row number of cell 1, column number of cell 1], [row number of cell 2, column number of cell 2]]
distRangeTruestring"A1:A20"The area to be filled, must include the source area, support cell name, "A1: B2" and two-dimensional racerans such as [[cell 1 line number, cell number 1 column number], [cell 2 line number, cell number 2 column number]] Two forms, using cell names when Case Sensitive

Demo

/************************Auto fill area************************ ********* 
**Input 1:
** objExcelWorkBook -- The workbook object returned by the "Open Excel Workbook" command (Excel.OpenExcel) or "Bind Excel Workbook" command (Excel.BindBook)
**Entry 2:
** sheet--If a string is used, it means the name of the specified worksheet; if a number is used, it means the order of the specified worksheet (starting from 0)
**Entry 3:
** srcRange--The specified range, supports cell names such as "A1:B2" and two-dimensional row and column arrays such as [[cell 1 row number, cell 1 column number], [cell 2 Row number, cell 2 column number]] two forms, case-insensitive when using cell names
**Entry 4:
** distRange--The range to be filled must include the source range, support cell names such as "A1:B2" and two-dimensional row and column arrays such as [[cell 1 row number, cell 1 column number ],[row number of cell 2, column number of cell 2]] two forms, case-insensitive when using cell name
**
*********************************************************************/
//Write the result value of the specified area to the area to be filled
objExcelWorkBook = Excel.OpenExcel(@res'''Test.xls''',true,"WPS","","")
Excel.AutoFill(objExcelWorkBook,"Sheet1","A1:A2","A1:A20")
TracePrint "Auto-fill area: Excel object 'Sheet1' worksheet gets the contents of A1:A2, and fills in repeatedly to A1:A20"
Excel.CloseExcel(objExcelWorkBook,True)