Hello!

I need get data of PivotCaches to ODC File, but a have the following error:


---------------------------------------------------------------------------
com_error                                 Traceback (most recent call last)
<ipython-input-5-8ecf280d3302> in <module>
      5     print(odc_name)
      6
----> 7     nivel_1.SaveAsODC(ODCFileName=odc_name)

c:\users\mdabati\appdata\local\programs\python\python36\lib\site-packages\win32com\gen_py\00020813-0000-0000-C000-000000000046x0x1x9\PivotCache.py
 in SaveAsODC(self, ODCFileName, Description, Keywords)
     59         def SaveAsODC(self, ODCFileName=defaultNamedNotOptArg, 
Description=defaultNamedOptArg, Keywords=defaultNamedOptArg):
     60         return self._oleobj_.InvokeTypes(2082, LCID, 1, (24, 0), ((8, 
1), (12, 17), (12, 17)),ODCFileName
---> 61    , Description, Keywords)
     62
     63  _prop_map_get_ = {

com_error: (-2147352567, 'Exceção.', (0, None, None, None, 0, -2147024809), 
None)

I'm use Python 3.65,  my code:

import urllib
import pandas as pd
import random
import win32com.client
Excel = win32com.client.gencache.EnsureDispatch('Excel.Application')

# URL file
url = 
'http://www.anp.gov.br/images/DADOS_ESTATISTICOS/Vendas_de_Combustiveis/Vendas_de_Combustiveis_m3.xls'

# Load URL
file_name, headers = urllib.request.urlretrieve(url)

# Load XLS
arq = Excel.Workbooks.Open(file_name)
PivotCaches = arq.PivotCaches()

for nivel_1 in PivotCaches.__iter__():
    odc_name = 'ODCFile_'+str(random.randint(1,100))
    print(odc_name)
    nivel_1.SaveAsODC(ODCFileName=odc_name)





Att.

Maikon  Abati
_______________________________________________
python-win32 mailing list
python-win32@python.org
https://mail.python.org/mailman/listinfo/python-win32

Reply via email to