简体   繁体   中英

Unable to import .py File created for excel sheet creation in Robot Framework

I've created a Python file for Excel sheet creation :

StoreOpenClose.py

import xlsxwriter

workbook = xlsxwriter.Workbook('Store_Open_Close.xls')
worksheet = workbook.add_worksheet()

bold = workbook.add_format({'bold': True})
worksheet.add_table('A1:H60')

worksheet.write(0, 0, 'ID ', bold) 
worksheet.write(0, 1, 'Zomato Outlet Name ', bold)
worksheet.write(0, 2, 'Enable On Zomato (Yes/No) ', bold)
worksheet.write(0, 3, 'Is Taking Orders Active (Yes/No) ', bold) 
worksheet.write(0, 4, 'DistributionPointActive ', bold)
worksheet.write(0, 5, 'OnChannelPartnerActive ', bold)
worksheet.write(0, 6, 'IsTakingOrders ', bold)
worksheet.write(0, 7, 'Zomato Status (Open/Close) ', bold)

worksheet.set_column('A:A', 5)
worksheet.set_column('B:B', 18)
worksheet.set_column('C:C', 25)
worksheet.set_column('D:D', 28)
worksheet.set_column('E:E', 21)
worksheet.set_column('F:F', 23)
worksheet.set_column('G:G', 14)
worksheet.set_column('H:H', 25)

worksheet.set_default_row(hide_unused_rows=True)


workbook.close()

Please can anyone suggest how to make it compatible to import to Robot Framework. As currently while importing it into Resources it is giving import error.

.py 文件导入错误

  • Import is as a Library instead of Resource , and see the documentation
  • Wrap Python library functionality into a function/functions
  • Make sure that the Python code runs without errors
  • Check that the path is correct

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM