1

Basically, I want to be to be able to pass data between Excel cells and my C++ program. I don't have any experience in Excel/C++ interactions and I haven't been able to find a coherent explanation or documentation on any websites. If someone could link me some references or provide one themselves it would be much appreciated. Thanks.

  • Do you mean you want to have your C++ program interact with a running instance of Excel with an Excel document open, or do you want to manipulate Excel files with your program by itself? The keyword for the former is "Office Automation", the latter is a much more difficult problem. – In silico Oct 10 '13 at 03:45
  • Manipulate Excel files by itself. I want it so that I can access certain sensitive information in an Excel file individually without having to run Excel. – Carter Saggio Oct 10 '13 at 03:47
  • 1
    In that case, you have a rather difficult problem. You need to parse the Excel file format, which is not a simple format in any sense. Parsing [the newer `.xlsx` file format](http://en.wikipedia.org/wiki/XLSX) is a bit easier, but the structure is still not trivial. If you instead accept only [`.csv` files](http://en.wikipedia.org/wiki/Comma-separated_values) (which Excel can generate), then it's significantly easier. – In silico Oct 10 '13 at 03:50
  • In that case, do you know of any way to make a large data table that's simpler to access then Excel? I suppose I could use matrices, but that'd be a very tedious way of going about it. – Carter Saggio Oct 10 '13 at 03:55
  • What is the syntax for accessing csvs? – Carter Saggio Oct 10 '13 at 04:00
  • csv's are one record per line with some sort of delimiter (comma, tab, space, etc.) between fields. – Seth Moore Oct 10 '13 at 04:04

2 Answers2

0

If this is for a Windows system, you could always use one of the available managed Excel libraries, such as OfficeWriter or Aspose.

There also might be similar libraries specifically for c++, I know we (OfficeWriter) used to make one.

Edit: Looks like there are a few out there, like LibXL and BasicExcel.

If the application will run on an end user machine with Excel installed, you can easily use the Excel interop and keep Excel hidden.

Community
  • 1
  • 1
Seth Moore
  • 3,575
  • 2
  • 23
  • 33
0

In addition to LibXL and BasicExcel mentioned by smoore, there is:

ExcelFormat Library is an improved version of the BasicExcel library and will allow you to read and write simple values. It is free.

xlslib will also read and write simple values, I have not tried it tho. It is also free.

Number Duck, is a commercial library that I have written, It supports reading and writing values, formulas and pictures. The website has examples of how to use the features.