Skip to main content

Write-Area

Command Description

Write a two-dimensional array into the specified region of the sheet. Performance will be compromised when the count of elements in the array is inconsistent

Command Prototype

Excel.WriteRange(objExcelWorkBook,sheet,strCell,data,bSave)

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)
strCellTruestring"A1"Two forms of cell are supported: cell names (such as "A1") or array of rows and columns (such as [row number, column number]). It is case-insensitive to use cell names
dataTrueexpression[[1,'one'],[2,'two'],[3,'three']]Data to be written, two-dimensional array. If the array elements used are not aligned, they will be automatically aligned with null values before written. Please note the effect to avoid value overwriting
bSaveTruebooleanNoneSave immediately after the operation

Demo

/************************Write area************************ ********* 
**Input 1:
** objExcelWorkBook--Excel workbook object (a workbook opened using the "Open Excel" command (Excel.OpenExcel) or a job bound using the "Bind Excel" command (Excel.BindBook) book object).
**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:
** strCell--Specified cell, supports two forms of cell name such as "A1" and row and column array such as [row number, column number]. When using the cell name, it is not case-sensitive.
**Entry 4:
** data--The two-dimensional array to be written. If the array elements used are not aligned, they will be automatically written after aligning the elements with null values. Please pay attention to the impact to avoid value overwriting.
**Entry 5:
** bSave--The operation is completed and saved immediately. (boolean true/false)
**
*********************************************************************/

objExcelWorkBook = Excel.OpenExcel(@res"Test.xlsx",True,"Excel","","")
Excel.WriteRange(objExcelWorkBook,"Sheet1","A15",[["a",1],["b",2],["c",3]],False)
TracePrint "Writing area: A set of data "&'[["a",1],["b",2],["c",3]]' is written in A15 of Excel object Sheet1 worksheet
Excel.CloseExcel(objExcelWorkBook,True)