Is there any way in .Net to convert an MS Office Powerpoint .PPT to .ODP?
I've searched the web, and I only see so-called online converters. I've ony found one commercial option, Aspose, which starts at $500.
Thanks.
There's nothing built in. You're looking at a third party library.
One option I know can work and is fairly easy to do is unoconv. It's just a command line script you can call. The problem is that you take on a lot of dependencies. You need Open Office installed, and the script is in python so you need that available, too.
There is a free online converter like alterapps.com , This works for me all the time. quick and efficient.
Related
I am searching from last two days but did not find any thing.
My requirement is to create a document viewer in my web application (C#.Net) and I don't want to use any third party tool for this. Can I convert the files in image or PDF or in any common formate which can be easly render on web page. I also can not use Introp object.
Any help will be highly appreciated
You mention in one of your comments that you'd like to write all the code yourself but don't know where to start. Here's how I would go about it...
First, you'll need to familiarize yourself with the Microsoft Office Format specification. You can find that here (there's a link to the technical specification). Office documents are actually a .zip file with an XML file inside along with any binary data representing attachments. Just renamed a .docx file as .zip and you'll be able to open it up and see the XML and any other supporting documents inside (same is true for xlsx, etc...).
Then you'll need to become intimately familiar with either PDF or HTML, as your job now will be to convert the various Office document structure into PDF or HTML structure, being sure to respect page layout, margins, order, etc...
As others have said, this is a large task which is why third party tools exist today. Also, each third party toolset has it's limitation as this is really hard to "get right" in all situations and there will be edge cases that work for one document and not another (because maybe they didn't use Microsoft Word to save the .docx, maybe they used OpenOffice and OpenOffice interpreted the standard slightly differently...)
If you cannot use COM/Interop technologies in your solution, you can take a look at the specialized 3rd party options. I see that you prefer not to use them, however, there are no existing built-in solutions in the .NET Framework. Check out my answer in a similar thread that describes how to accomplish exactly the same task using 3rd party libraries (for example, DevExpress, since I have experience with it). In addition, take a look at the Documents demo, where you can see how to create images/thumbnails from different types of MS Office documents.
I believe what you need is an intermediate representation of the documents which can be converted into an image for the viewer to display.
Lets me try to explain with the below diagram:
You can use tools like smallpdf or OfficeToPDF to do that. Just integrate them into your application.
Small PDF(https://smallpdf.com/library-detail)
officetopdf (https://officetopdf.codeplex.com/)
First of all I want to say hi to the programming community, what I am looking for is a way to generate a report from my Windows Forms Application in word preferably, this report is basically a list of pre-configured days in a tour creation software I am creating.
I have searched everywhere and I cant seem to find information on how to start creating the report, I have all the information saved into a database, I just need to be able to get this information into word and ordered as it should be ordered.
I just want to be pointed in the right direction so I can research on it even further.
The exact thing I want to create is a word file that I wish I could share here so you can actually see what I mean.
Thank you for all your attention and help if possible.
I can point you in the right direction. Word documents are stored in a format called OpenXml which can be created and manipulated without actually using Word directly. That's good because you don't want to deal with code that actually starts an instance of Word and automates it (Interop.) It sort of works but it's not something I recommend dealing with ever.
OpenXml isn't fun either, but it's better. You can create your document "normally" using Word, save it, and then have your application use it as a template, opening a copy, populating some data, and then saving it.
Here's the reference for OpenXml with Word. I'm not saying it's pretty. It's not. The documentation is lacking. This page on adding text isn't linked from the previous page, even though many other topics are.
There are some nuget packages like this one that can help.
I once did a POC that did exactly what you're describing by opening and altering a document used a template using OpenXml. I'll see if I can dig up the code. But this is definitely a good direction to look in if Word is an absolute requirement.
This is a long shot, but can you output in HTML? If you can that's an even easier alternative.
Can you use Excel? That's also OpenXml but there's easier-to-use tools like EPPlus that simplify dealing with it, because it's not just the friendliest thing to work with.
An option that I would suggest is Crystal Reports. You can download the Crystal Reports add-in for Visual Studio for free from here. Crystal Reports is an easy way to perform reporting from various data sources including SQL. There are also a lot of free tutorials online for learning how to use CR. The syntax is a little strange, but it is easy enough to use.
The add-in allows you to create reports for your application and also build applications that can display, print, and export Crystal Reports.
You can export reports to .RTF (Rich Text Format) files. MS Word can open, edit, and convert RTF documents. It does a fairly decent job, but special formatting might take some work. This route is a ton easier than trying to write XML or anything else. I've written several reports designed for export to RTF. My boss runs the report, exports it, then edits it in Word. He loves the reports.
If you are planning on developing a lot of reports, purchasing the full version of Crystal Reports is well worth it. I believe they are on version 2016 currently.
If you do want to deal with automating Word, Microsoft's guide "Automating Applications Using the Office Object Model" Word-specific task content is here: https://msdn.microsoft.com/en-us/library/78whx7s6(v=vs.80).aspx
A larger example: https://support.microsoft.com/en-us/kb/316384
To begin, simply add an assembly reference to your project file for the correct Office Object Library (example: "Microsoft Word ##.0 Object Library"). Note that you must have Office installed to take this approach.
Good luck!
I would like to use NPOI library to get image from Word file (Doc [97-2003]).
I want to HWPFDocument class, but i can not find namespace, where this class is. I write code in c#.
I don't think you can achieve that using NPOI.
As tonyqus (the guy behind the project) states here and here HWPF is not stable and usable.
I've managed to work with MS Word and Excel with "OpenOffice uno SDK".
It's not straightforward but after a little bit of struggle you can have great results.
You can read how to extract and use the assemblies here and how to achieve what you're looking for here.
Of course you can always use MSOffice Interop but you need to install MS Office on the client where the application is executed.
Hope it helps.
I'm looking for any available free Excel "helper" classes that are written for .net (doesn't have to be C#).
I'd like to evaluate what others consider to be useful and generic static (and non static) helper methods.
Can be targeted at VSTO or regular Office automation, although that probably doesn't matter.
I guess I should also point out that this question is NOT asking for "what are good alternatives (or free alternatives) to using Excel object model automation. I don't really want links to SS gear, etc, although they are all great products that's not the purpose of the question.
In case I wasn't clear enough in the previous paragraph: I don't want answers that state - use this free (or not free) 3rd party component, instead of Excel object model code.
So basically what i was asking for was user developed C# code libraries that contain VSTO, Office or Excel helper functions such as static methods for working with menus, ribbons, ranges, workbooks, documents, xml (such as the ones otaku mentioned)...
VSTO Power Tools is a good set of utilities to work with Excel:
http://msdn.microsoft.com/en-us/magazine/dd263100.aspx
ExcelDNA is a very cool project. It provides a lightweight way to consume .NET code from Excel, with a deployment model which is much easier than VSTO. I found it an interesting alternative to VSTO if you want to write UDF in .NET for instance.
In terms of Office automation for Excel, there are some good PowerShell Open XML cmdlets that can be used for PS or ported to C# at Announcing the Release of PowerTools for Open XML V1.1. Eric White's blog, where this link is, has recently done an more in depth look at Excel automation using Open XML, like Table Markup in Open XML SpreadsheetML. Note about Open XML - although it is the preferred method by many, you don't actually have to use the Open XML SDK - you can just use System.IO.Packaging to gain access to Excel 2007/2010 files.
Also, often overlooked, but the Excel snippets available for VSTO, Open XML and Interop development are great. 1, 2, 3
Also, check out the Excel samples for VB # http://msdn.microsoft.com/en-us/library/8x19fbw1(v=VS.90).aspx. These come installed with VS when you also choose VB as a language during the install.
Update: Just discovered the All-In-One Code Framework (Office) which has a lot of great Excel helper classes. You can find it on: http://1code.codeplex.com/releases/view/51868.
For VSTO projects:
http://www.add-in-express.com/
Non-VSTO, non-automation:
http://www.html-to-pdf.net/excel-library.aspx
Note: neither of these libraries are free.
There's one called FileHelpers which enables you to save Excel data as CSV and the FileHelpers library can easily parse the information and so on, sure it may not be fully blown Excel automation, but it is a good headway to parsing. If you're talking about being able to deal with Excel in a native binary fashion, then this article from CodeProject might help, also here, is BIFF parser that understand the underlying excel data storage, and also here on CodeProject.
With .net 4.0 dynamic keyword writing Excel automation easy as hell.
If you want intellisense you can easily write c# wrapper on top of dynamic calls.
UPDATE
We are working with Excel automation since 2001 (developing financial addins).From Excel 2000 up to 2010.
And all we know that standard interop simply does not work when your code should work with all versions and service packs of Office.
We had beaten many times by custom interop libraries, VSTO versions, etc. After a year we found a only one solution that works - call all automation via late bound calls (reflection). i.e. (''notepad code'') Type.GetTypeFromProgId('Excel.Application').GetMethod('Visible').Invoke(....).
But code was very big and ugly, then we simply wrap that ugly code with Object Model copied from Excel 1:1. When we need new method we add it to our Excel Object model and call excel automation via late bound call.
With new dynamic keyword it is possible to live without wrapper especially with Resharper's dynamic support.
I prefer this one:
Excel Package on CodePlex
it uses the Open XML, so no need for an office install on the computer (may or may not factor in), but I found it very easy to use and set up.
I really like NPOI for 2003/2007 formats
http://npoi.codeplex.com/
Totally standalone and easy to use
would anyone suggest a free solution to programmatically convert Office documents (mostly .doc) to PDF in the form of a .NET library or a command-line application i can call from my program? Thanks
PS: I know I can use SaveAs PDF in newer versions of Office, but some of the clients where the program will run still have older versions of Office.
Won't GhostScript (GhostScript Website) do that for you? Otherwise, I think, under reserves, that PDFSharp might do it. If these won't do, I hope that this one will: PDFCreate. In fact, after a closer look, if Ghostcript won't do, I would perhaps consider trying PDFCreate as it provides some sample code on the wbesite I linked for it.
You might also want to consult Wikipedia on the topic: List of PDF software
You can maybe use something like PrimoPDF which basically installs a printer that when you print to it, creates a PDF document. I've never actually called it command line but since it's just another printer, any standard print code would work.
Cody