Convert xls file into a xlsx file

Hello,

Is it possible to convert a Excel file from *.xls into *.xlsx in C++?
But not in C# using .NET Framework.
And without using instances of Microsoft Excel.

Thanks for help.
Best regards
Fujitsufan
With the increasing number of nooses you wish to tie around your neck, comes the increase in the amount of work you need to do for yourself.

https://docs.microsoft.com/en-us/openspecs/office_file_formats/ms-offfflp/8aea05e3-8c1e-4a9a-9614-31f71e679456

Is there a reason you need to do it in C++? What is your objective?
it is possible, yes.
1) excel can do it
2) c++ can do pretty much anything that can be done on a computer, and nothing here is that exotic, its a binary file in, binary file out, bit of gibberish in the middle to convert it. The few things c++ can't do are not even remotely in this area of coding needed to pull it off.

so that proves it can be done. Not everything that can be done, should be done, of course.
Last edited on
it is possible, yes.

I'm curious how it can be done in C++ without using system commands.

I see, right off the bat, there is libxl[0], a C++ Excel library that can read and write Excel files.

[0]: http://libxl.com/
ill give you a simpler example, as M$ formats are bloated and confusing.
say you wanted to convert a bitmap to a tga. you would read the file in, extract the RGB array of image data, and its dimensions etc from the header, then write the new header for the new type with the dimensions etc and data. This one is easy, its just different header formats on the data blob. But you do it the same way, you pull the original apart into its parts and then build the new file with those parts, using some default for anything that you didn't have in the old file, discarding anything you didn't need, etc. But its going to be crazy complex... you have the cell data, macros, formulae, embedded passwords, fonts, cell formatting, and probably hundreds of other bits of info that you have to extract from the original and insert correctly into the new one. There can be embedded buttons and such, basic code, and more to handle! Cell colors. Column widths. Merged cells. I think you can even add images and sounds. Author's personal info stolen from their pc is embedded. File version. ... yuck!
Last edited on
Author's personal info ... is embedded.

BTK anyone?
Foiled by metadata!
The only reason I can see for perhaps wanting to do this is to convert a lot of files, where it would be inconvenient to have to keep opening Excel.

Does the methodology suggested here work?
https://gist.github.com/Opiprog/8bb6f491578d4f23540ccd98e85288c3
or
http://justgeeks.blogspot.com/2014/08/free-convert-for-excel-files-xls-to-xlsx.html
I haven't actually tried using excelcnv.exe, although that converter certainly exists in the Office 15 folder.

If you want to convert a lot of files just issue the command repeatedly with a batch file: I can't see any good reason for using C++ here.


EDIT: OK; it seems to work.
Last edited on
BTK anyone?
Foiled by metadata!

pretty much lol. Take a look though -- the M$ suite embeds everything knows about you if not told to stop doing that. Or it used to. Maybe privacy laws caught up to them now.
Registered users can post here. Sign in or register to post.