0

I am trying to search a way to access excel sheet properties using C language. What i found on internet they are for C# etc. actually I will be modifying the text properties of an excel sheet in RPi using C language. Plz suggest is there any way. Thanks in advance.

Sidk
  • 1
  • 6

2 Answers2

0

If you're talking specifically about Excel spreadsheets, it is not possible to use C in order to interface directly with Excel. As you mentioned, it is possible to use C#. That's because Microsoft happens to provide an API for that language but doesn't for C.

You could try a XLSX library such as this one (although it is in C++) in order to create spreadsheets.

Dhaivat Pandya
  • 6,499
  • 4
  • 29
  • 43
0

It is probably in principle possible to do what you want (Microsoft provides a C API for Excel) but using it seems fairly involved. A relatively low-tech solution might be to use VBScript as an intermediary. There is a wealth of information on automating Excel with VBScript and it is easy to invoke these scripts from the command line (with e.g. the data you want written to a file passed as a command line argument). See this question. Furthermore, you can use a system call to invoke this from C (using system from stlib.h. This is round-about but you can break the problem into 2 steps: writing the VBScript and then figuring out how to invoke it from C.

Community
  • 1
  • 1
John Coleman
  • 51,337
  • 7
  • 54
  • 119
  • Thanks John i would like to try this but will it work for RPi too? – Sidk Aug 09 '15 at 05:43
  • @Sidk I wouldn't think it would work *directly* in RPi. My answer was mostly about a way to get data from a C program to an Excel document. Presumably the document itself isn't on the RPi and you are using some link to a machine running Windows. Does that link allow you to run system calls? Maybe this contains some helpful ideas: https://www.raspberrypi.org/forums/viewtopic.php?f=91&t=67836&p=495685 (that part about XML format sounds promising). – John Coleman Aug 09 '15 at 10:48
  • yeah checked thanks for the link, any idea how can i use this excel XML format in my C code? – Sidk Aug 09 '15 at 13:28
  • @Sidk This link gives information on Excel XML: http://blogs.msdn.com/b/brian_jones/archive/2005/06/27/433152.aspx For writing XML in a specific format you can probably do it yourself, although doubtless you would be reinventing wheels already invented in libraries like: http://www.xmlsoft.org/index.html – John Coleman Aug 09 '15 at 14:45