How can an OpenOffice document be created in C++ [duplicate]
Asked Answered
B

3

3

Possible Duplicate:
Creating, opening and printing a word file from C++

Hi,

I need to create a word document from a c++ program, Im using windows 2008 server,office automation fails sometimes here and also I need non interactive service to handle as automation provides interactive service.I've implemented automation it fails sometimes

What are the ways I can create openoffice / word doc?

can you please suggest me any links or tutorials to do the above.

PS - I came to know about couple of methods 1.Openoffice SDK 2.OpenXML SDK

If you have worked with the above please suggest me which of the above to use.

Thanks in advance

Bridlewise answered 28/4, 2011 at 5:17 Comment(11)
@paul R - Please check the above qestion you've linked speaks about office automation, embedding word document. I need to create an openoffice word document through a c++ program may be using officeopen XML or openoffice SDK.Bridlewise
@Greenhorn: What's wrong with using Office automation? You don't need to embed a Word document in your programs to take advantage of Office automation. It's totally possible to use it just for exporting out to an Office document. Unless you're not targeting a Windows system...Airspace
@In silico: isn't it dependent on a Windows + Office install? That's a pretty big issue. The question is tagged with openoffice but could make this restriction clearer....Grassofparnassus
@Tony: It is dependent on a Windows+Office install, but I find that in most cases that's not actually a problem. But if this is an issue for Greenhorn, then the OP should make it clearer in the question.Airspace
@In silico - Im using windows 2008 server,office automation fails sometimes here and also I need noninteractive service to handle as automation provides interactive service.I've implemented automation it fails sometimes.Bridlewise
@Greenhorn: Ah, okay. That is a rather important requirement that you should state in the question itself.Airspace
"OpenOffice" sounds a lot like OpenOffice.org, an Oracle product, whereas "Word" seems to refer to Microsoft Word for Windows. They're two distinct products (product lines). Furthermore, they both can deal with mutiple file formats. The question is confusing all of them.Corcoran
@ MSalters - I need create any of the one msword or openoffice doc.Bridlewise
Office Automation is NOT safe for a server. This is absolutely NOT a duplicate of the other question mentioned and answers about office automation are not appropriate.Kaminsky
@ Paul R, Greg S, MSalters, Bo Persson, Graviton - I don't see how this is duplicate of the question #146073 as I've clearly mentioned I'm programming in server and automation fails at time here.Bridlewise
this is not a duplicate. not one of Paul R, Greg S, MSalters, Bo Persson, Graviton have any badges in any Office programming tags - its clear those that closed it don't understand the technologies being discussed here. moving to re-open.Anaphora
A
7

Here's a newly released C library called libOPC which has the same intent as the Open XML SDK, but can be used in all of Linux/Windows/Mac/etc. You can read about it here: libOPC version 0.0.1 released and get the code from CodePlex (be sure to check the documentation page for demo videos).

Anaphora answered 28/4, 2011 at 16:56 Comment(0)
K
2

Using the Open Office XML SDK and Open Office XML directly are good options if you're targeting Word 2007 and up.

If you're targeting users of Word 2003 and earlier then it may not be the best option. However, even those users can install a free filter to be able to open Word 2007 (.docx) documents within Word 2003. You can link to this download from your application. Most people with Word 2003 or earlier probably have this filter installed anyways since they will often run into situations where people share newer files.

http://www.microsoft.com/DOWNLOADS/en/details.aspx?familyid=941b3470-3ae9-4aee-8f43-c6bb74cd1466&displaylang=en

Open Office XML SDK is a .NET API for reading and writing .docx and other Office 2007 files. If you're using C++/CLI then you can use this easily enough and it will simplify the process of writing .docx files.

http://www.microsoft.com/downloads/en/details.aspx?FamilyId=C6E744E5-36E9-45F5-8D8C-331DF206E0D0&displaylang=en

However, if you're using straight C++ with no .NET, then you cannot use the SDK. This isn't a huge loss though. The SDK is only a very slight wrapper around the XML files anyways. A docx file is just a zip with a bunch of XML files inside. There are some oddities in relationships between the files and where text is stored and how some things are referenced positionally instead of by ids, which is generally considered a very bad practice with XML. Regardless though, those issues are easily worked around and you can create .docx files manually without too much trouble. In fact, creating is much easier than reading.

The SDK is still useful in that it contains a file exploration tool that will give you a graphical explorer for existing files. When you want to know how to create particular content, do it within Word 2007, save the file, and then look at what the file contains.

Kaminsky answered 28/4, 2011 at 16:47 Comment(0)
O
1

I advise you to look at this page where the author explains what solution he took to generate Word documents on a server, without MsWord being available, without automation or thirdparty libraries.

Onfre answered 28/4, 2011 at 7:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.