+ 1

Convert XLS File to CSV

Has anyone worked on a program to convert Excel XLS files to CSV? I have found numerous resources, but can't seem to get them to work in Visual Studio. I'm most familiar with C#, but if anyone has had luck with other languages please let me know. Thanks in advance.

17th Oct 2019, 6:06 PM
Brandon
Brandon - avatar
8 Antworten
+ 2
You can do it in Python using numpy and one of the Python Excel libraries. It’s not so complicated
17th Oct 2019, 9:15 PM
Rora
+ 8
One way to overcome the learning curve is to make a copy of the Excel file, change the extension from .xlsx to .zip, extract the zip to a folder, and open that folder using VS Code, Sublime, Notepad++, etc like it's a project. You can then see how all the XML files and elements map to the loaded object model. Just place a breakpoint after the OpenXML document is loaded and expand on the object properties while debugging. By having the files accessible in a text editor, you quickly search against all XML files for quick reference. -------- Another Option: Create an SSIS Job -------- SSIS would be an easier option where you can use it to load an Excel file and map columns from the source file to a target table and / or a CSV file. This could then be saved as an SSIS job which could run as Excel files are dropped into a specific location.
18th Oct 2019, 5:34 AM
David Carroll
David Carroll - avatar
+ 6
Have you attempted to do this with OpenXML? If not, that should be what you need to extract data from the Excel Document Object Model. What other resources have you seen so far?
17th Oct 2019, 10:48 PM
David Carroll
David Carroll - avatar
+ 2
I second David Carroll 's suggestion. Assuming you have a need to do this task programmatically, I have used OpenXML with C# for this. There's a bit of a learning curve in using it, but once you understand the structure of a document/spreadsheet, it's a breeze. Mind you it's easier to read and parse a file than it is to build something from scratch with OpenXML. There are many examples out there that will show you how to do what you need.
18th Oct 2019, 2:21 AM
Mike
Mike - avatar
+ 2
thank you all for your suggestions!
18th Oct 2019, 3:43 AM
Brandon
Brandon - avatar
+ 2
David Carroll no problem. I was trying to remember the name of the tool earlier but it slipped my mind until today when I actually used it for one of my own projects lol.
5th Nov 2019, 8:20 PM
Mike
Mike - avatar
+ 1
One thing to add... if you want a program to help you understand the structure of a document in OpenXML, download the OpenXML productivity tools. It can help you understand how to write your code.
5th Nov 2019, 1:51 PM
Mike
Mike - avatar
0
Mike... Bruh... I had no idea that little tool existed. 🤦‍♂️ I've actually learned a lot on my own by extracting the document XML files out into a folder, then opening the folder as a project in Sublime, Notepad++, or VS Code for closer review. I've also learned a ton by reviewing the source code in OpenXML and OpenXML PowerTools as well as stepping through the code debugger while running their unit tests. Next time, I'll know to check this tool out. Thanks for sharing that bit of knowledge man. 🤓👌
5th Nov 2019, 8:13 PM
David Carroll
David Carroll - avatar