在尝试使用XLRT,XLWT和Xlutils在现有文件中附加数据时,是否可以在Excel文件(XLS)中保存宏?

发布于 2025-02-10 19:39:26 字数 460 浏览 0 评论 0原文

我基本上试图使用XLRD XLWT和Xlutils中的现有Excel文件(.xls)中的相关单元格添加数据。我能够将数据放在文件中的相关单元格中,但是,在此过程中未保留宏按钮。有什么办法可以将数据附加到XLS文件中,而不会干扰宏(或原始文件)?

我尝试了这样的事情将值集成到所需的单元格中:

    import xlwt
    import xlrd
    import xlutils.copy import copy
    rb=xlrd.open_workbook('try.xls')
    wb=copy(rb)
    w_sheet=wb.get_sheet(0)
    w_sheet.write(0,2,15)
    wb.save('try.xls')

我是这样这样做的,因为我需要将一些值放在现有的XLS文件中,然后使用文件中存在的按钮来执行进一步的操作。我是新手。任何帮助将不胜感激。谢谢!

I am basically trying to add data to concerned cells in an existing excel file(.xls) using xlrd xlwt and xlutils. I am able to put the data to the concerned cell in the file, however, the macro buttons are not preserved in this process. Is there any way that I can append my data to the xls file without disturbing the macros(or the original file)?

I tried something like this to incorporate the values to the required cells:

    import xlwt
    import xlrd
    import xlutils.copy import copy
    rb=xlrd.open_workbook('try.xls')
    wb=copy(rb)
    w_sheet=wb.get_sheet(0)
    w_sheet.write(0,2,15)
    wb.save('try.xls')

I am doing it this way as I need to put some values in an existing xls file and then use that to perform further operations using the buttons present in the file. I am new to this. Any help would be appreciated. Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文