Replies: 7 comments
-
If I understand correctly, all you have to do is make sure you are using from styleframe import StyleFrame
sf = StyleFrame({'b': [5, 6, 7, 8]})
writer = StyleFrame.ExcelWriter('existing.xlsx', mode='a')
sf.to_excel(writer, sheet_name='new sheet')
writer.save() This will preserve all styling of existing sheets while adding a new sheet called 'new sheet'. |
Beta Was this translation helpful? Give feedback.
-
@DeepSpace2 - No, i wish to write to an already formatted sheet in an excel file. We manually did all the formatting like color, font, merged cells etc as a header. Now, i want my pandas output to be written to that specific formatted sheet ( where i start from row = 8). Hope this helps. I don't wish to add a new sheet |
Beta Was this translation helpful? Give feedback.
-
@DeepSpace2 - In addition to my comment above, when i specify the exact sheet that i want to write to with append mode and sheet exists = overlay, it strips all the formatting. Thats the problem. Or you mean to say that I should use |
Beta Was this translation helpful? Give feedback.
-
@DeepSpace2 - Thanks, it works now. However, one question. Is it possible to write to the file keeping excel open? Currently, the permission is denied to write if I keep the file open. Is there anyway, that I can do this wriite operation by keeping the file open? |
Beta Was this translation helpful? Give feedback.
-
@SSMK-wq No, that's a limit imposed by your OS. |
Beta Was this translation helpful? Give feedback.
-
Hello @SSMK-wq |
Beta Was this translation helpful? Give feedback.
-
@Cata801 Can you please check if StyleFrame.read_excel_as_template works for you in this case? You read the excel, update the values you want and save (for tests I suggest saving as another file :) ) |
Beta Was this translation helpful? Give feedback.
-
Hi, I am posting this here as I came to know about Styleframe from SO.
Would like to know whether it is possible to write a pandas output to formatted excel file?
I have a dataframe like as shown below
I would like to write this dataframe to a specific sheet (called temp_data) in the file
output.xlsx
Therfore I tried the below
I also tried the below
But am not sure whether I am overcomplicating it. I get an error like as shown below. But I verifiedd in task manager, no excel file/task is running
Moreover, I also lose my formatting of the
output.xlsx
file when I manage to write the file based on below suggestions. I already have a neatly formatted font,color file etc and just need to put the data inside.Is there anyway to write the pandas dataframe to a specific sheet in an existing excel file? WITHOUT LOSING FORMATTING OF THE DESTIATION FILE
Beta Was this translation helpful? Give feedback.
All reactions