user2746078
user2746078

Reputation: 107

Disable Protected View mode in Excel files - with xlwt , python

I'm using formulas:

wsheet.write(i, j, Formula('HYPERLINK(%s;"Link")' % click), docnm)

in my Excel files

and when it first opens up it goes into "Protected View". My formulas don't load until after I click "Enable Editing". Is there anyway to get my numbers to show up even if Protected Mode is on?

I found a similar topic on this link Protected View in Microsoft Excel 2010 and Python , but there aren't any useful answers.. Can someone help me please?

Complete code:

        from xlwt import easyxf,Formula
        import xlwt   
        wbook = xlwt.Workbook()
        wsheet = wbook.add_sheet("MySheet")
        wsheet.col(j).width = 17000

        link="https://stackoverflow.com/"
        click="http://ccwebviewer.ac.de.eu.ericsson.se/~"+excelbranch+link
        click='"'+str(click)+'"'
        linkName='"'+"LINK"+'"'
        wsheet.write(1, 1, Formula('HYPERLINK(%s;%s)' % (click,linkName)))
        wbook.save("excel.xls")

Upvotes: 1

Views: 4979

Answers (1)

ChrisProsser
ChrisProsser

Reputation: 13098

I have tried a basic example with the code below and seem to be able to open the workbook produced without a prompt and follow the link:

import xlwt

link_url = 'http://stackoverflow.com/questions/21430921/disable-protected-view-mode-in-excel-files-with-xlwt-python' #'file1.csv'
outputfile = 'outputList.xls'
wbk = xlwt.Workbook()
wsheet = wbk.add_sheet('sheet 1')

xlformula = 'HYPERLINK("'+link_url+'", "Link")'
wsheet.write(0, 0, xlwt.ExcelFormula.Formula(xlformula))

wbk.save(outputfile)

This basically creates a new workbook and writes a link to the URL for this question and saves the workbook.

Upvotes: 3

Related Questions