# Tag Sync from excel file built with python script is not working. openpyxl vs pywin32

**URL:** <https://forum.vtscada.com/t/tag-sync-from-excel-file-built-with-python-script-is-not-working-openpyxl-vs-pywin32/965>\
**Category:** General Discussions\
**Created:** [May 31, 2025, 5:18am UTC](https://forum.vtscada.com/t/tag-sync-from-excel-file-built-with-python-script-is-not-working-openpyxl-vs-pywin32/965 "2025-05-31T05:18:09Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![mahin101](https://forum.vtscada.com/user_avatar/forum.vtscada.com/mahin101/32/673_2.png) [@mahin101](https://forum.vtscada.com/u/mahin101)\
**Post date:** [May 31, 2025, 5:18am UTC](https://forum.vtscada.com/t/tag-sync-from-excel-file-built-with-python-script-is-not-working-openpyxl-vs-pywin32/965/1 "2025-05-31T05:18:09Z")

</div>

tldr: openpyxl dont work, pywin32 works. My question is why?

…

Openpyxl way =\>

```auto
import os
from openpyxl import load_workbook
 

wb = load_workbook("./exported_from_vt.xlsx")
ws_context = wb["Context"]
ws_context.sheet_state='visible'

r = ws_context.max_row+1
ws_context.cell(row=r,column=2, value="Asia22")
ws_context.cell(row=r,column=10, value="Asia22")

r+=1
ws_context.cell(row=r,column=2, value="Asia22\\\\Himalayas")
ws_context.cell(row=r,column=10, value="Himalayas")

r+=1
ws_context.cell(row=r,column=2, value="Asia22\\\\Ocean")
ws_context.cell(row=r,column=10, value="Ocean")

# wb.save("exported_from_vt.xlsx")
wb.save("to_sync.xlsx")

```

1. I first go to vtscada application configuration to generate the current snapshot of tags (exported\_from\_vt.xlsx)
2. this python code inserts rows in the excel sheet to add 3 vt tags and saves the file (to\_sync.xlsx)
3. Then i take the _to\_sync.xlsx_ file and **Sync** to vtscada
4. But VT do not take any tags, says: _0 deleted, 0 added_

But when instead of [openpyxl](https://pypi.org/project/openpyxl/) , I use [pywin32](https://pypi.org/project/pywin32/) package and its methods, VT Sync works fine.

```auto
import win32com.client as win32
import os

input_file = os.path.abspath("./exported_from_vt.xlsx")
output_file = os.path.abspath("./to_sync.xlsx")

excel = win32.gencache.EnsureDispatch("Excel.Application")
excel.Visible = False 

wb = excel.Workbooks.Open(input_file)

ws_context = wb.Worksheets("Context")

ws_context.Visible = -1

xlUp = -4162
last_row = ws_context.Cells(ws_context.Rows.Count, 1).End(xlUp).Row
r = last_row + 1

ws_context.Cells(r, 2).Value = "Asia22"
ws_context.Cells(r, 10).Value = "Asia22"

r += 1
ws_context.Cells(r, 2).Value = "Asia22\\\\Himalayas"
ws_context.Cells(r, 10).Value = "Himalayas"

r += 1
ws_context.Cells(r, 2).Value = "Asia22\\\\Ocean"
ws_context.Cells(r, 10).Value = "Ocean"

wb.SaveAs(output_file)

wb.Close(SaveChanges=0)
excel.Quit()

```

(I’m posting this question for future reference actually, letting other people know about openpyxl vs pywin32 behaviour)  
I asked chatgpt…

![Screenshot 2025-05-31 104512.png](https://forum.vtscada.com/uploads/default/original/1X/1f2b09251ec515ba0b40be3a638eb167b11eb342.png)
