Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I maintain column headers when adding all sheets to a book? #258

Open
unique0ne0 opened this issue Apr 2, 2022 · 0 comments
Open

Comments

@unique0ne0
Copy link

Hi.

I love to use pyexcel. Thanks.
I have a question.
Just now I realized column headers are gone after some processes with a single sheet, which has column headers assigned by sheet.name_columns_by_row(0).
When I save a file with a single sheet, column headers are ok, but when I save a file as a book after adding, they are gone.

for example..
after inputting header names and data into each sheet..

sheet1.name_columns_by_row(0)
sheet2.name_columns_by_row(0)

sheet1:
+------------+--------+--------+
| column1 | column2| column3 |
+======+======+=====+
| 1 | 2 | 3 |
+------------+--------+--------+

sheet2:
+------------+--------+--------+
| columnA | columnB| columnC |
+======+======+=====+
| A | B | C |
+------------+--------+--------+

book1 = sheet1 + sheet2
book1. save_as(book1_filename)

I naturally thought every sheet in book1 must have column headers, but the result is like below..

sheet1:
+------------+--------+--------+
| 1 | 2 | 3 |
+------------+--------+--------+

sheet2:
+------------+--------+--------+
| A | B | C |
+------------+--------+--------+

when I save each sheet as a separate file, the headers are ok.
So if I use merge_all_to_a_book, it works ok in this case, the headers are not disappeared but this is very complex.
moreover, I have to change sheet names.
This is not a beautiful solution.

Please let me know what I should do to maintain column headers when I add sheets.
I have to use this book at the next process, but it failed because they don't have column names.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant