Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/329.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/python-3.x/17.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
尝试使用openpyxl python修改1个单元格时,Excel文件已损坏_Python_Python 3.x_Excel_Vba - Fatal编程技术网

尝试使用openpyxl python修改1个单元格时,Excel文件已损坏

尝试使用openpyxl python修改1个单元格时,Excel文件已损坏,python,python-3.x,excel,vba,Python,Python 3.x,Excel,Vba,我正在尝试使用openpyxl更改启用宏的excel 2013文件中的1个单元格。这应该是一个相对容易的任务,我有下面的代码,它可以工作,但由于某种原因,当我稍后尝试打开修改后的excel文件时,我从excel中得到错误消息 我们发现“工作簿”中的某些内容有问题。是否要恢复 如果我恢复文件,它会从文件中删除很多内容,但我仍然可以看到我要修改的唯一单元格具有正确的数据 打开错误日志时,我收到以下消息: <?xml version="1.0" encoding="UTF-8" standalo

我正在尝试使用openpyxl更改启用宏的excel 2013文件中的1个单元格。这应该是一个相对容易的任务,我有下面的代码,它可以工作,但由于某种原因,当我稍后尝试打开修改后的excel文件时,我从excel中得到错误消息

我们发现“工作簿”中的某些内容有问题。是否要恢复

如果我恢复文件,它会从文件中删除很多内容,但我仍然可以看到我要修改的唯一单元格具有正确的数据

打开错误日志时,我收到以下消息:

<?xml version="1.0" encoding="UTF-8" standalone="true"?>
-<recoveryLog xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main">
<logFileName>error086600_01.xml</logFileName>
<summary>Errors were detected in file 'C:\Files\2018 Workflow\Stress Due Date (NA) --- TR9999999 Pckg#9 - Emergency Equipment - 9 - 9 - 9\Panel Analysis --- 9 Version A.xlsm'</summary>
-<repairedParts summary="Following is a list of repairs:">
<repairedPart xml:space="preserve">Repaired Part: /xl/worksheets/sheet1.xml part. </repairedPart>
 </repairedParts>
 </recoveryLog>

您的问题并显示
+excel\u ext
@stovfl excel\u ext=“.xlsm”抱歉,无法再现您的问题。
""" 
The next part of the script will modify the stress panel excel documents 
"""    
wb = load_workbook(filename = os.path.join(new_path,new_panel + excel_ext), read_only = False, keep_vba = True) 
ws = wb.get_sheet_by_name("Adapter_Panel_Tool")
ws['C2'] = "Adapter Panel Quick Stress Analyses Tool - " +  packet_list['Installations list'][0]
wb.save(os.path.join(new_path,new_panel  + " Version A" + excel_ext))
wb.close()


#checks if there are 2 files: the filled one and the empty one and deletes the empty if it exist. 
is_file_filled_out = os.path.isfile(os.path.join(new_path,new_panel + " Version A" +  excel_ext))
is_there_empty_file = os.path.isfile(os.path.join(new_path, new_panel + excel_ext))
if is_file_filled_out == True and is_there_empty_file == True:
    os.remove(os.path.join(new_path,new_panel + excel_ext))
    print("\n\n The following file will be remove: \n" + new_panel + excel_ext + "\n\n" )
    print("The prefilled template has been created: \n " + new_path + new_panel + excel_ext)