-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathUnhideAllWorksheets.py
61 lines (31 loc) · 1.1 KB
/
UnhideAllWorksheets.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
49
50
51
52
53
54
55
56
57
58
59
60
from xml.dom import minidom
import os
import lxml.etree as et
## Rename the file
#os.rename('testdata.twb',"testdata.xml")
xmldoc = et.parse('test3.xml')
root = xmldoc.getroot()
for window in root.iter('window'):
if window.get('class') == ('hidden-worksheet'):
window.set('class', 'worksheet')
#print window.get('class')
xmldoc.write('output.xml', encoding = 'utf-8', pretty_print=True,inclusive_ns_prefixes='xsi')
os.rename('output.xml',"output.twb")
#itemlist = xmldoc.element();
#print itemlist;
#xmldoc.write('test2.xml')
# # ## parse the XML doc
# xmldoc = minidom.parse('testdata.xml')
# ##find the window of the sheet
# itemlist = xmldoc.getElementsByTagName('window') [4]
# #itemlist.pop(0)
# ## set the class to worksheet and test
# print itemlist.getAttribute('class')
# itemlist.setAttribute('class' , 'worksheet')
# print itemlist.getAttribute('class')
# #os.rename('testdata.xml',"testdata.twb")
# xmldoc = et.parse('testdata.xml')
# xmldoc.write('test2.xml')
# #print itemlist[0].attributes['name'].value
# # for s in itemlist[1:] :
# # print s.attributes['name'].value