I have an Excel template file which has columns as defined within an XML. Manually I can right click over the template then XML > import, and select the XML file, and finally save the file.
How can I perform this task automatically programming it in Python?
Example of XML file:
<DCPowerFlow>
<branches>
<branch>
<busFrom name="bus_one" number="1" />
<busTo name="bus_two" number="2" />
<id>1</id>
<rateA>1000</rateA>
<resultPowerFlow>
<probOverFlow>0.0</probOverFlow>
<maxOverFlow>800</maxOverFlow>
</resultPowerFlow>
</branch>
<branch>
<busFrom name="bus_two" number="2" />
<busTo name="bus_three" number="3" />
<id>1</id>
<rateA>1200</rateA>
<resultPowerFlow>
<probOverFlow>0.1</probOverFlow>
<maxOverFlow>1300</maxOverFlow>
</resultPowerFlow>
</branch>
</branches>
</DCPowerFlow>
To check for the manual task:
- Save the above example as an XML file.
- In order to create the Excel XLS template you can simply open the above XML example with Excel, ensure no data is on the template (delete data if within the import you added any) and save the file as XLS.
- Import the example XML file. Right click on the Excel template file created, then XML > Import, and select the XML example file.
- Save Template with data as a new XLS.
So what I need to do is to automate steps 3 and 4.