I'm currently developing application using WinRT/C#. It is second version, first was developed on WPF. In application I need to generate some reports and export them into MS Word document.
In first version of application I used MS Office Interop to export reports in MS Word, but in WinRT there is no support of MS Office Interop. Is there any simple way to create MS Word document in WinRT? (I know there are third party libraries like Syncfusion for WinRT but I would prefer to not use them).
You won't be able to use MS Office interop from a Windows Store app. You could use Open XML SDK, though. It is also available on NuGet and seems to be WinRT compatible.
Using it won't be as easy as working with interop classes and you'll only be able to create XML based docx files, not binary doc files. On the other hand your users won't need to have Word installed and they'll be able to open the files in other Office suites like OpenOffice or LibreOffice. There's a set of tutorials available on MSDN to get you started.
There is a free solution that consiste to format your document in rtf.
For this i create a new librairy to help a developper to create a document compatible with word.
you can find this there : https://github.com/crogun/WinRTF-For-WinRT
the code is open source, and you can extend it if you want.
Related
The project in which I'm involved has a requirement of generating Word documents.
Initially, I used Interop to achieve this. But since Interop requires the clients to have Office installed on their machines, I switched over to OpenXML instead.
Interop has a nice method for getting Content Controls by title "SelectContentControlsByTitle", is there any alternative to this in OpenXML?
Cheers!
I've done find and replace solution in Micorsoft.Office.Interop.Word in asp.net I would like to move this solution on NetOffice in my asp.net server where there is no Microsoft Word. I got error
progid not found
. What I do wrong because on my computer where I have Microsoft Word this code work fine in NetOffice?
Word.Application wordApp = new Word.Application(); <-- here is this error
NetOffice is just a COM Wrapper to the office applications, therefore it requires that you have the office app installed on the machine where your application is running.
i.e. You need to have Microsoft Word installed on any machine that you intend to run an app that uses NetOffice.Word.
If this was a desktop app, all you would have to do, would be to install Word on the machine, but given you want to use office automation from a server, and Microsoft does not recommend it, you should look into other options of interfacing with Word documents directly via OpenXML without having to install Word on the machine.
I'd recommend taking a look at the DocX library:
https://github.com/WordDocX/DocX
As well as the articles below:
How to: Create a word processing document by providing a file name (Open XML SDK)
Edit Word Documents using OpenXML and C# Without Automation/Interop
Your code should work with NetOffice, but you need to add a using statement:
using Word = NetOffice.WordApi;
You also need to disable the setting Embed Interop types for all NetOffice DLL's.
I want to access to office 2003 files (.doc, .xls and .ppt) in order to extract text and some metadata (number of words, number of sheets, pictures, template, etc.). I'm able to do it with Open XML SDK for office 2007 documents. However, this extracton will take place on a server, which can't have apps like Microsoft Office installed (that's the reason why I can't use Office's Interop).
I have tried NPOI, however actually it only supports .xls files. The other libraries that I found are not open-source, I can't use it on my work... I downloaded NPOI Scratchpad but the code is very "raw", I can't use it on my work.
Do you have any other idea to get the text and metadata from office 2003 documents? I'm not a very experienced programmer, and I'm using C# (However, if there is any solution to this problem in C++ I could consider to use it). Thanks.
There are many libraries like:
ClosedXML (Office 2007)
EPPlus (Office 2007)
Aspose cells(Office 97-2010, I use this one)
I don't know any free libraries supporting office 2003 format.
good luck
Is there a way to remove the metadata information of MS Word files or Image files programmatically using C# or a Windows batch command?
The manual way to remove those information is to right click a file in the windows explorer and selecting 'Properties'>'Details'>'Remove Properties and Personal Information'.
It ain't easy, at least not to get it all.
You might look at the metadata removal package called Metadact by Litera (formerly Softwise).
There are several others out on the market too.
If you want to do it yourself, first, you'll need to decide on what you consider "metadata".
Some is pretty easy to get to using the Word Object Model (Interop from C# or VB).
Some can't be accessed via Word, so you'll need to use the Structured Storage API to get at it (Like last 10 authors).
If you're talking about DOCX files, you can use the OpenXML SDK to get at all the packages inside the file. then use XML to navigate and edit out the bits you don't want.
Going that way, though, it's MUCH harder to remove "metadata" in the content of the document, because you'll have to deal with internal Word structures like RUNs, and change tracking stuff.
Thanks!
I think I found way to remove (or add) meta information to office documents. There is a Microsoft article here: The Dsofile.dll files lets you edit Office document properties when you do not have Office installed (KB 224351)
The Dsofile.dll sample file is an in-process ActiveX component for
programmers that use Microsoft Visual Basic .NET or the Microsoft .NET
Framework. You can use this in your custom applications to read and to
edit the OLE document properties that are associated with Microsoft
Office files, such as the following:
Microsoft Excel workbooks
Microsoft PowerPoint presentations
Microsoft Word documents Microsoft
Project projects Microsoft Visio drawings
Other files that are saved in the OLE Structured Storage format
The Dsofile.dll sample file is
written in Microsoft Visual C++. The Dsofile.dll sample file
demonstrates how to use the OLE32 IPropertyStorage interface to access
the extended properties of OLE structured storage files. The component
converts the data to Automation friendly data types for easier use by
high level programming languages such as Visual Basic 6.0, Visual
Basic .NET, and C#. The Dsofile.dll sample file is given with full
source code and includes sample clients written in Visual Basic 6.0
and Visual Basic .NET 2003 (7.1).
i wrote a app for reading excel files.i had to add some references to Microsoft office Com Objects.
it worked good in my system,but when i wanted to use it in other system in which does`t had ms office installed ,
i encounter a problem.i also carried dll files that has been added to project . what should i do ?
In order to use the relevant object libraries you'll have to make sure that Office (Excel in your case) is installed on your client machine. If you have the option I'd suggest to switch to the Open Office XML format anyways. I recently had a similar problem with MS Word and the +work to switch to the new format has def. payed of.
Check MS Open XML SDK
Performace++ and not depending on Office installed...
The Office COM objects depend on Office. You should either arrange for Office to be installed on the other systems, or use a component for reading Excel files that doesn't need Excel installed, such as the ODBC Excel driver or a third-party Excel file reader.