Python: How to open a multisheet .xslx file (with formatting) and edit a few cells and save it as another .xlsx file
Question: I have tried using openpyxl but it seems to fail when I am saving the file
(<http://pastebin.com/VU5LTajH>) and I cannot find any info about the problem.

Any other modules that let you read edit and save an .xlsx file while
retaining the style and formatting of the original file?


Answer: You can use win32com library (I assume that you're working on Windows) and
dispatch excel application via COM. Inside, you can use every method that is
available in VBA (so that's good to work with [Object model
reference](https://msdn.microsoft.com/en-
us/library/office/ff194068%28v=office.15%29.aspx) as documentation).

Below simplified example how I use it.

    
    
    import win32com.client
    excel = win32com.client.gencache.EnsureDispatch ("Excel.Application")
    excel.Visible = True
    workbook = excel.Workbooks.Open(filepath)
    if isinstance(worksheetName, str):
        worksheet = workbook.Worksheets(worksheetName)
    else: #assume that worksheetName is number
        sheet = workbook.Worksheets[worksheetName]
    
    def getRange(worksheet, address):
        return worksheet.Range(address)
    
    def getValue(range_):
        """Returns values from specified range, as tuple of tuples (even if range
        is single row) or single value if range is one cell"""
        return range_.Value2
    
    def setValue(range_, values):
        range_.Value2 = values
    

As I see workbook object has method `SaveAs`, so I'd use it to save it as
another file after changing cells value, like this:

    
    
    workbook.SaveAs("newFilename")
    

