1

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")
Community
  • 1
  • 1
user2746078
  • 107
  • 4
  • 11
  • can you provide your full code please. – ChrisProsser Jan 29 '14 at 12:58
  • I can, now I will edit my question – user2746078 Jan 29 '14 at 13:04
  • I can copy paste complete code because it's private Code , this just part of my code that is modified, but why you need my code , is posiblle via python , xlwt disable Protected view in Excel, that is my question????? – user2746078 Jan 29 '14 at 13:12
  • Why do I need your code? It turns out in this case that I didn't, I have posted a generic example below, but very often a little context helps a lot. I really don't think that this is a lot to ask given that you are asking for people help with no reward. – ChrisProsser Jan 29 '14 at 13:25

1 Answers1

3

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.

ChrisProsser
  • 12,598
  • 6
  • 35
  • 44
  • 1
    I tried your example and trully Protected View window isn't shown , but in my excel view Protected view always shows , without HYPERLINK or with HYPERLINK, my question is how to Disable Protected view ? is there eny option in xlwt ? What cause shown up of protected view ? – user2746078 Jan 29 '14 at 13:29
  • 1
    I think that my file will be always opened in Protected view , because it's the file opened from the Internet, I return my excel fiel as Django response – user2746078 Jan 29 '14 at 13:32
  • 1
    That may be the case. The cost I posted above is the full code, so I have not done anything explicit to unprotect the sheet. – ChrisProsser Jan 29 '14 at 13:50
  • 2
    @user2746078 On further investigation there are setting in Excel e.g. in Excel 2010 it under File -> Options -> Trust Center -> Trust Center Settings -> Protected View. Unfortunately I think these would need to be changed on the client machine. – ChrisProsser Jan 29 '14 at 13:54