Programming Excel file in C ++

I saw programs exporting to Excel in two different ways.

  • Opening Excel and entering a data cell by cell (during its operation, it looks like a working macro)
  • Creating an Excel file on disk and writing data to a file (for example, the function of export to MS Access)

Number 1 is terribly slow, and for me it's just merciless.

Number 2 is what I need to do. I guess I need some kind of SDK so that I can create Excel files in C ++.

  • Do I need different SDKs for .xls and .xlsx?
  • Where can I get them? (I tried Googling, but the SDKs I found look like they are doing other things than providing an interface for creating Excel files).
  • When it comes to runtime, does MS Office require a PC to create Excel files, or do you get a redistributable DLL that you can deploy with your executable?
+7
source share
3 answers

You can easily do this using the Excel XML format. Check out wikipedia about this:

http://en.wikipedia.org/wiki/Microsoft_Excel#XML_Spreadsheet

This format was introduced in Excel 2002, and it is an easy way to generate an .xls file.

+9
source

You can also try to work with XLS / XLSX files on top of ODBC or ADO drivers, as databases with limited use. You can use some templates if you need to format or create files from stratch. Of course, you are limited to playing with such field values. For styling, etc. You will need to use the Excel API, for example Microsoft .

0
source

I do this through the Wt WTemplate library

In short, I created the required Excel document in an open office and save-as format excel 2003 (.xml) .

Then I uploaded it to google-chrome to make it look beautiful and copied it to the clipboard.

Now I carefully break it into templates so that Wt can render a new file every time.

0
source

Source: https://habr.com/ru/post/902369/


All Articles