xlsx2csv icon indicating copy to clipboard operation
xlsx2csv copied to clipboard

[Feature Request] Save each sheet as a file instead of combining into one single sheet

Open caffeinatedMike opened this issue 3 years ago • 4 comments

It would really be useful to have the ability to convert a multi-sheet xlsx file into multiple csv files instead of dumping all the text onto one sheet. Maybe the sheet names can be appended to the outfile name to create orderly filenames?

caffeinatedMike avatar Jun 02 '21 00:06 caffeinatedMike

Use -s 0 option Example: xlsx2csv -s 0 excelfile.xlsx /directory/to/write/to/ This accomplishes what you are asking for

SirCujo avatar Aug 23 '21 18:08 SirCujo

From what the documentation provides that does not appear to be the behavior. Why else would there be sheet delimiter options? This implies all sheets are combined into a single csv and the rows of data separated via the delimiter per sheet.

caffeinatedMike avatar Aug 23 '21 18:08 caffeinatedMike

I just ran it, and thats what it did. Just trying to help you out. I needed the same functionality.

Did you try it, or just dismiss my help?

SirCujo avatar Aug 23 '21 18:08 SirCujo

Similar to what @SirCujo mentioned, you can run twice to each sheet. The concept is:

step 1. dump everything

xlsx2csv -a excelfile.xlsx all.csv

step 2. find how many sheet your name and export every one of them

grep -- '--------' all.csv  ## this prints out sheet names
for i in {1..2}; do  xlsx2csv -s $i excelfile.xlsx sheet.$i.csv

Or just use what @SirCuju has mentioned, use -s 0 is the trick to dump all sheets in a output directory.

zhanxw avatar Jan 20 '22 15:01 zhanxw