Multiple issues with saving .xlsx file as a .csv

%3CLINGO-SUB%20id%3D%22lingo-sub-1761777%22%20slang%3D%22en-US%22%3EMultiple%20issues%20with%20saving%20.xlsx%20file%20as%20a%20.csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1761777%22%20slang%3D%22en-US%22%3E%3CP%3EI%20haven't%20done%20this%20in%20a%20while%2C%20but%20I'm%20now%20trying%20to%20convert%20an%20.xlsx%20file%20to%20a%20.csv%20file.%20I%20need%20to%20have%20a%20.csv%20file%20to%20import%20a%20bunch%20of%20data%20into%20a%20computer%20system%20at%20work.%20I've%20done%20this%20before%20and%20it%20has%20never%20been%20an%20issue.%20Now%20I'm%20having%20a%20bunch%20of%20issues.%20The%20biggest%20problem%20is%20that%20my%20source%20.xlsx%20file%20contains%20cells%20with%2010-digit%20codes%20and%20some%20of%20them%20start%20with%20one%20or%20more%20zeros.%20In%20the%20source%20file%2C%20I%20have%20these%20cells%20set%20to%20%22text%22%20formatting%20so%20that%20Excel%20doesn't%20wipe%20the%20leading%20zeros.%20I%20click%20%22Save%20As%22%2C%20select%20%22.csv%22%2C%20enter%20a%20file%20name%20and%20location%2C%20and%20click%20%22Save%22.%20The%20system%20pops%20up%20a%20new%20Excel%20window%20with%20the%20newly%20created%20CSV%20file%2C%20and%20the%20data%20looks%20correct.%20However%2C%20when%20I%20close%20that%20new%20file%20and%20then%20reopen%20the%20file%20by%20double-clicking%20it%20in%20my%20destination%20folder%2C%20it%20opens%20Excel%20and%20shows%20that%20the%2010-digit%20codes%20have%20been%20converted%20from%20text%20to%20numbers%2C%20and%20thus%20Excel%20sees%20fit%20to%20drop%20any%20and%20all%20leading%20zeros!%20I%20thought%20the%20purpose%20of%20a%20.csv%20file%20was%20to%20store%20information%20without%20touching%20the%20formatting.%20Now%20these%20codes%20are%20not%20only%20worthless%2C%20but%20dangerous%2C%20because%20if%20I%20accidentally%20imported%20them%20into%20my%20work%20system%2C%20it%20would%20corrupt%20a%20bunch%20of%20other%20information%20because%20it%20won't%20recognize%20the%20codes%20properly.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EOk%2C%20second%20issue%20I'm%20seeing%20is%20that%20my%20source%20.xlsx%20file%20has%20multiple%20tabs.%20I%20want%20to%20be%20able%20to%20create%20one%20.csv%20file%20for%20each%20tab%20in%20the%20.xlsx%20file.%20I%20open%20a%20certain%20tab%20and%20go%20through%20the%20process%20above%20to%20save%20as%20a%20.csv%20file.%20Excel%20pops%20up%20a%20warning%20that%20converting%20to%20.csv%20will%20drop%20formatting%20and%20will%20only%20convert%20the%20active%20tab%20to%20a%20new%20.csv%20file.%20I%20click%20%22Ok%22%20and%20then%20the%20newly%20created%20.csv%20file%20opens%20automatically%20(like%20I%20mentioned%20above).%20However%2C%20instead%20of%20seeing%20a%20new%20.csv%20file%20with%20only%20one%20tab%20(from%20the%20active%20tab%20in%20the%20source%20file)%2C%20I'm%20seeing%20all%20of%20the%20tabs.%20If%20I%20close%20and%20open%20the%20file%20-%20which%20blows%20up%20my%2010dig%20codes%20like%20I%20said%20above%20-%20all%20of%20the%20tabs%20are%20still%20there.%20I%20have%20no%20idea%20what%20would%20happen%20if%20I%20tried%20to%20import%20that%20new%20.csv%20file%20into%20my%20computer%20system%20at%20work...%20but%20I'm%20guessing%20it%20would%20be%20bad.%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EI%20chatted%20with%20Microsoft%20Help%20and%20they%20basically%20said%20that%20this%20is%20the%20way%20it's%20supposed%20to%20be%2C%20which%20I'm%20pretty%20sure%20is%20NOT%20accurate.%20Has%20anybody%20else%20seen%20this%20stuff%20happening%3F%20Any%20fixes%20out%20there%20that%20I%20can%20try%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CP%3EThanks%20in%20advance...%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-1761777%22%20slang%3D%22en-US%22%3E%3CLINGO-LABEL%3EExcel%3C%2FLINGO-LABEL%3E%3CLINGO-LABEL%3EOffice%20365%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1762077%22%20slang%3D%22en-US%22%3ERe%3A%20Multiple%20issues%20with%20saving%20.xlsx%20file%20as%20a%20.csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1762077%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F825480%22%20target%3D%22_blank%22%3E%40superbeau%3C%2FA%3E%26nbsp%3B%3C%2FP%3E%3CBLOCKQUOTE%3E%3CHR%20%2F%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F825480%22%20target%3D%22_blank%22%3E%40superbeau%3C%2FA%3E%26nbsp%3Bwrote%3A%3CBR%20%2F%3E%3CP%3EI%20click%20%22Save%20As%22%2C%20select%20%22.csv%22%2C%20enter%20a%20file%20name%20and%20location%2C%20and%20click%20%22Save%22.%20The%20system%20pops%20up%20a%20new%20Excel%20window%20with%20the%20newly%20created%20CSV%20file%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3CHR%20%2F%3E%3C%2FBLOCKQUOTE%3E%3CP%3EThis%20doesn't%20happen%20on%20my%20system.%3C%2FP%3E%3CP%3EAnd%20you%20don't%20%3CSTRONG%3Eopen%3C%2FSTRONG%3E%20csv%20with%20Excel%20but%20%3CSTRONG%3Eimport%3C%2FSTRONG%3E%20csv%20into%20Excel%20-%20either%20the%20legacy%20way%20or%20the%20Power%20Query%20way.%3C%2FP%3E%3CP%3ECheck%20the%20csv%20content%20with%20a%20text%20editor.%20Does%20it%20show%20leading%20zeros%3F%3C%2FP%3E%3CP%3E%26nbsp%3B%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1763785%22%20slang%3D%22en-US%22%3ERe%3A%20Multiple%20issues%20with%20saving%20.xlsx%20file%20as%20a%20.csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1763785%22%20slang%3D%22en-US%22%3E%3CP%3E%3CA%20href%3D%22https%3A%2F%2Ftechcommunity.microsoft.com%2Ft5%2Fuser%2Fviewprofilepage%2Fuser-id%2F1639%22%20target%3D%22_blank%22%3E%40Detlef%20Lewin%3C%2FA%3E%26nbsp%3Byes%2C%20if%20I%20open%20the%20.csv%20file%20in%20Notepad%2C%20the%20leading%20zeros%20are%20there.%20So%20I%20guess%20I%20should%20just%20plan%20to%20Save%20As%20a%20.csv%20file%20and%20then%20not%20open%20that%20file%20again%20with%20Excel.%20But%20I%20wonder%20why%20then%20Excel%26nbsp%3B%3CEM%3Eopens%3C%2FEM%3E%20the%20newly%20formed%20.csv%20file%20automatically%20in%20an%20Excel%20window%20right%20after%20you%20create%20it%3F%20And%20why%20does%20that%20file%20look%20correct%2C%20but%20if%20you%20close%20and%20reopen%2C%20it%20gets%20messed%20up%3F%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-SUB%20id%3D%22lingo-sub-1763792%22%20slang%3D%22en-US%22%3ERe%3A%20Multiple%20issues%20with%20saving%20.xlsx%20file%20as%20a%20.csv%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-1763792%22%20slang%3D%22en-US%22%3E%3CP%3EAlso%2C%20I%20should%20have%20mentioned%20that%20I%20use%20Office%20365%2C%20so%20I%20have%20the%20latest%20version%20of%20Excel%20running%20in%20Windows%2010%20Pro%20(64%20bit)%20on%20a%20Surface%20Book%20laptop.%3C%2FP%3E%3C%2FLINGO-BODY%3E
Highlighted
Occasional Contributor

I haven't done this in a while, but I'm now trying to convert an .xlsx file to a .csv file. I need to have a .csv file to import a bunch of data into a computer system at work. I've done this before and it has never been an issue. Now I'm having a bunch of issues. The biggest problem is that my source .xlsx file contains cells with 10-digit codes and some of them start with one or more zeros. In the source file, I have these cells set to "text" formatting so that Excel doesn't wipe the leading zeros. I click "Save As", select ".csv", enter a file name and location, and click "Save". The system pops up a new Excel window with the newly created CSV file, and the data looks correct. However, when I close that new file and then reopen the file by double-clicking it in my destination folder, it opens Excel and shows that the 10-digit codes have been converted from text to numbers, and thus Excel sees fit to drop any and all leading zeros! I thought the purpose of a .csv file was to store information without touching the formatting. Now these codes are not only worthless, but dangerous, because if I accidentally imported them into my work system, it would corrupt a bunch of other information because it won't recognize the codes properly.

 

Ok, second issue I'm seeing is that my source .xlsx file has multiple tabs. I want to be able to create one .csv file for each tab in the .xlsx file. I open a certain tab and go through the process above to save as a .csv file. Excel pops up a warning that converting to .csv will drop formatting and will only convert the active tab to a new .csv file. I click "Ok" and then the newly created .csv file opens automatically (like I mentioned above). However, instead of seeing a new .csv file with only one tab (from the active tab in the source file), I'm seeing all of the tabs. If I close and open the file - which blows up my 10dig codes like I said above - all of the tabs are still there. I have no idea what would happen if I tried to import that new .csv file into my computer system at work... but I'm guessing it would be bad.

 

I chatted with Microsoft Help and they basically said that this is the way it's supposed to be, which I'm pretty sure is NOT accurate. Has anybody else seen this stuff happening? Any fixes out there that I can try?

 

Thanks in advance...

7 Replies
Highlighted

@superbeau 


@superbeau wrote:

I click "Save As", select ".csv", enter a file name and location, and click "Save". The system pops up a new Excel window with the newly created CSV file

 


This doesn't happen on my system.

And you don't open csv with Excel but import csv into Excel - either the legacy way or the Power Query way.

Check the csv content with a text editor. Does it show leading zeros?

 

Highlighted

@Detlef Lewin yes, if I open the .csv file in Notepad, the leading zeros are there. So I guess I should just plan to Save As a .csv file and then not open that file again with Excel. But I wonder why then Excel opens the newly formed .csv file automatically in an Excel window right after you create it? And why does that file look correct, but if you close and reopen, it gets messed up?

Highlighted

Also, I should have mentioned that I use Office 365, so I have the latest version of Excel running in Windows 10 Pro (64 bit) on a Surface Book laptop.

Highlighted

@superbeau 


@superbeau wrote:

But I wonder why then Excel opens the newly formed .csv file automatically in an Excel window right after you create it?


I have no idea. It does not happen on my system.

 

Highlighted

@superbeau 

To create separate csv files for each worksheet you may use powershell , sample is here Convert Excel file (XLSX) to CSV in Powershell , or similar VBA script, or manually: right click on sheet, Move or Copy, check Copy, from destination select new book and from it save as csv. Content will be in Excel window since that's default application for csv files. Modern Excel save all csv sheets into the file if Save As.

 

If close and open csv file in Excel again it performs default conversions, that was for all versions. In particular, numbers saved as texts will be converted back to numbers (but not only, there are another conversions). I don't know about workaround, the only not to open in Excel but import to Excel using legacy wizard or Power Query. In both cases mark proper columns as having Text type. 

Highlighted
Highlighted

@superbeau , you are welcome