-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateexcel.py
48 lines (38 loc) · 1.11 KB
/
updateexcel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
# -*- coding: utf-8 -*-
__author__ = 'Jorge Jara H'
__copyright__ = "Copyright 2022, RPA Project"
__license__ = "CC Attribution-NonCommercial-NoDerivs 4.0 International"
__version__ = 1.0
__maintainer__ = "Jorge Jara H"
__email__ = "[email protected]"
__status__ = "production"
from pickle import TRUE
import win32com.client as win32
import time
from datetime import datetime
PATH = 'C:/directorio_base/'
book_update = [
"archivo1.xlsx",
"carpeta/archivo2.xlsx",
"archivo3.xlsx",
]
def update_book(book):
print("Abriendo Libro: " + book)
EXCEL = win32.DispatchEx('Excel.Application')
INFORME = EXCEL.Workbooks.Open(PATH + book)
EXCEL.Visible = False
EXCEL.EnableEvents = False
time.sleep(3)
print("Inicio actualización: " + book)
INFORME.RefreshAll()
EXCEL.CalculateUntilAsyncQueriesDone()
print("Fin actualización: " + book)
INFORME.Save()
INFORME.Close(True)
EXCEL.Application.Quit()
print("Libro Cerrado: " + book)
print("")
print("Inciando update....")
for book in book_update:
update_book(book)
print("Fin update.... Gracias por preferirnos...")