Skip to main content

Open or Create Spreadsheet

Command description

  • If the specified spreadsheet file already exists, the command opens it without recreating, deleting, or clearing it.
  • By default, openpyxl reads and writes .xlsx files directly without launching Microsoft Office or WPS Office.
  • Office and WPS modes use a COM interface. The Visibility parameter controls whether the application window is shown.
  • After reading or writing data, use Close Spreadsheet to release resources. To access the spreadsheet again after closing it, reopen it with Open or Create Spreadsheet.

Command Input Parameters

input parametersInput parameter typeDescription
Applicationenumopenpyxl, WPS, Office; openpyxl reads and writes .xlsx files directly, while WPS and Office use a COM interface
VisibilityenumHide, Show; applies only when WPS or Office is selected
File LocationstrSpreadsheet path, such as C:\files\report.xlsx; a relative path is resolved under the current user's Documents\RPA directory

Command Output Parameters

Output parametersOutput parameter typeDescription
Excel ObjectExcelAppThe opened spreadsheet object; use its path attribute to get the full file path
tip

openpyxl mode does not require Microsoft Office or WPS Office. It supports .xlsx and attempts to preserve macros in existing .xlsm files. If the path has no extension, .xlsx is added automatically. The older .xls format is not supported, and formula results are not recalculated. Select Office or WPS when exact display formatting, formula recalculation, or .xls compatibility is required.

Example

Read each cell in sequence