Guest User

Untitled

a guest
Jan 16th, 2018
110
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. def Out_Excel(file_name,C,col):
  2. writer = pd.ExcelWriter(file_name,engine='xlsxwriter')
  3. for tab in tabs: # tabs here is provided from a different function that I did not write here to keep it simple and clean
  4. df = DataFrame(C) # the data is different for different sheets but I keep it simple in this case
  5. df.to_excel(writer,sheet_name = tab, startcol = 0 + col, startrow = 0)
  6. writer.save()
  7.  
  8. Out_Excel('test.xlsx',C,0)
  9. Out_Excel('test.xlsx',D,10)
  10.  
  11. import pandas as pd
  12. from openpyxl import load_workbook
  13.  
  14. book = load_workbook('test.xlsx')
  15. writer = pd.ExcelWriter('test.xlsx')
  16. writer.book = book
  17. writer.sheets = dict((ws.title, ws) for ws in book.worksheets)
  18.  
  19. df.to_excel(writer, sheet_name='tab_name', other_params)
  20.  
  21. writer.save()
Add Comment
Please, Sign In to add comment