I want to be able to add more in Python StyleFrame without overwriting Excel.

Asked 2 years ago, Updated 2 years ago, 94 views

I would like to use StyleFrame to save it without overwriting it on Excel, but it doesn't work.

I tried with StyleFrame.ExcelWriter(s_path,mode='a')aswriter:.
I couldn't do it because I got an error.

I would appreciate it if you could let me know.

python pandas

2022-09-30 17:41

1 Answers

The styleframe seems to be a wrapper for pandas and openpyxl, so ExcelWriter is probably calling it pandas.

styleframe

Library that wraps pandas and openpyxl and allow easy styling of dataframes.

Docs BBasic Usage Examples

Creating ExcelWriter object:

ew=StyleFrame.ExcelWriter(r'C:\my_excel.xlsx')
sf.to_excel(ew)
ew.save()

For the time being, there is a mode= parameter in the ExcelWriter of the pandas:

pandas.ExcelWriter

class pandas.ExcelWriter(path,engine=None,**kwargs)

  • path:string.BinaryIO
  • engine:str(optional)
  • date_format:str, default None
  • datetime_format:str, default None
  • mode: {'w', 'a'}, default 'w'
  • storage_options:dict, optional

In the styleframe specification document below, there is no ExcelWriter item, and I am not sure how to call it (whether the parameters are passed directly to Pandas?).:

Docs AP API Documentation st styleframe

Looking at the source code, it seems that it does not accept parameters other than path.

style_frame.py#L310

@classmethod
def ExcelWriter(cls, path):
    return pd.ExcelWriter(path,engine='openpyxl')

Therefore, mode='a' will not work.

The alternative is read_excel() and then add data to that styleframe before to_excel().


2022-09-30 17:41

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.