Windows 8 Metro Style App - Editing Word Documents - c#

I am trying to read/write to a word (.docx) in a W8 metro app. For normal .NET Applications there are many libraries, but non of them are avaliable for Windows Store apps (e.g. Open XML SDK 2.5 is not supported in RT Apps).
The only way, it might work is via the xml document using Windows.Data.Xml.Dom which is going to be a lot of work. Has anyone accessed word documents with the Windows.Data.Xml.Dom (or any other library) and would like to share his code?

I don't have any first hand experience, but I'd take a look at the following two alternatives before falling back to raw XML processing:
Your best bet could be DocIO from Syncfusion. It's not free but the price is really reasonable considering how much work it could save you. And there's even a free beta available.
Chris Klug created a simple OpenXML library for Silverlight. You could check if it does what you need and then try porting it to WinRT since the source is available.

Related

IFilter replacement

I'm currently using IFilters to extract text from various file (word, excel, tiff, pdf etc). I understand that IFilters have been discontinued with Windows 8. Does anyone have any recommendations on how to extract text without the native apps being installed? If it's any use I'm using C# and .Net 4
IFilter is not discontinued. Only the Windows Indexing Service is discontinued in favor of Windows Search or Microsoft Search Server. Both continue to use IFilters.
According to this documentation, the main point of compatibility for IFilters going forward are that they support the IPersistStream interface. All modern implementations should avoid requiring IPersistStorage, so they don't have to access the disk themselves.

create ppt programmatically using C# [duplicate]

Is there a way to programmatically create PowerPoint presentations? If possible, I'd like to use C# and create PowerPoint 2003 presentations.
Yes, you can.
You will want to look into MSDN which has a pretty good introduction to it.
I might give you a word of warning, Microsoft Office interop is compatible with an API which is now more than 10 years old. Because of this, it is downright nasty to use sometimes. If you have the money to invest in a good book or two, I think it would be money well spent.
Here's a starting point for you. Use the search feature on MSDN MSDN Webpage. It's good for any Microsoft C# .NET style stuff.
Specifically in regards to your question, this link should help: Automate PowerPoint from C#. EDIT LINK NOW DEAD :(. These two links are fairly close to the original KB article:
Automate Powerpoint from C# 1/2
Automate Powerpoint from C# 2/2
Finally, to whoever downvoted this: We were all learning one day, how to do something as a beginner is most definitely programming related, regardless of how new someone might be.
OpenXML looks like the way to go from a web app.
Using the interop libraries is not recommended, as others have stated.
You can also look at Aspose Slides, a component for .NET and Java that makes it easy to generate powerpoint documents.
If you don't really need PowerPoint compatible output, consider using a markup language such as LaTeX with the Beamer package to produce a PDF of the presentation, or use HTML and javascript in a manner similar to Slidy. If you need fancy effects, it might still be easier to use SVG, and you'd have the benefit of getting output that can be reliably viewed with free software.
http://msdn.microsoft.com/hi-in/magazine/cc163471(en-us).aspx
Use this link. Although this is in VB.NET, C# supports the same.
You may also try out SlideMight, a tool for merging hierarchical data with PowerPoint templates.
SlideMight supports:
text substitution in text fields, tables and notes
image substitution, from raw data, files and URLs
images in tables nested
iterations over data to create slides
iterations to populate tables, possibly spanning multiple slides
special formatting for specific cell values
hyperlinks to generated slides
Input data format is at this time just JSON.
There are versions for Windows and Mac OS X.
More information is at http://www.SlideMight.com
Disclaimer:
I am the owner of Delftware Technology, the company that developed SlideMight.
And I am one of the developers.
You can use Essential Presentation product from Syncfusion Software Private Limited. This product can be used to
Create and manipulate PowerPoint presentations
Open, modify, and save existing PowerPoint presentations
Convert PowerPoint presentations to PDF or Image
More information is at https://help.syncfusion.com/file-formats/presentation/overview
Disclaimer:
I work for Syncfusion Software Private Limited

How to change font in word document

I'm wondering how can I change the font (+ color and some font style) for the whole word document (excluding the page headers, if it's possible) by using C# ?
If You know any libraries (also commercial) feel free to let me know.
(After changing the font, I'll convert that word document to PDF using ABCPdf)
Depending on the library you would loop through the content (Pages/Paragraphs etc.) and change whatever font attribute you want...
Since you don't say which type of application you build - in case it is a pure desktop application and Word is guranteed to be installed locally you can use Office Interop. BEWARE that Office Interop is NOT supported by MS in server-scenarios (like IIS, ASP.NET. Windows Service, WCF etc.).
IF Word is not guaranteed to be installed and/or your application is not a desktop application and your Word documents are always DOCX files you could use OpenXML SDK V 2 from MS (free).
Otherwise I can recommend Aspose.Words (commercial) - works with old DOC and current DOCX and is usable in any type of application (desktop, ASP.NET, Windows Service etc.).
Handling Office documents in .NET is a quite straight forward task. Have a look at Microsoft.Office.Interop.Word, it is pretty well documented. Here is another link on to how you can change a word document font style using .NET (the example is in VB but is easily convertible to C#)
Start by reading on Microsoft.Office.Interop.Word
(You can google some user-friendly examples, there are tons)
Later on, read about Text Formatting
Easy, isn't it?

Word document generation

Our product is going to support Word(and PDF) report generation, and I'm investigating on which techniques to choose.
Currently what I know is Word automation and OpenXML SDK. There are pros & cons of each.
Do you have any experiences, suggestions or comments about these two or any other techniques? Or is there any third-party utilities/products(may be based on the previous two techniques or not) we can use? We want to analyze as many possible solutions as possible.
If you have the choice I'd go for OpenXML any day of the week.
It has quite a number of advantages over Office Automation.
The most interesting one for me is the fact that it can run on a server, where Office Automation can't (because you need an instance of office on the pc/server running your software). That brings us to my second point, it doesn't need an instance of Office to generate your documents, where Office automation needs one. (This is because office automation will run an instance of office in the background and perform all your actions on it).
Especially when we are talking about large documents or being able to generate quite a few at the same time, OpenXML will perform a lot better than Office Automation because of this.
To make a long story short, Office automation is a thing of the past, openXML is the future ;)
If you want to dive into OpenXML, take a peek here: OpenXML Developer
Good luck !
For PDF generation I used http://www.html-to-pdf.net in past. This provides good support and I assume can be used to generate word documents as well... Check out there website...
If you are using Web forms, I faced one issue with HTTPS - which I listed the solution here:
http://blogs.msdn.com/b/sajoshi/archive/2010/12/13/using-pdfconverter-http-www-html-to-pdf-net-with-https-in-asp-net-mvc.aspx
Docmosis offers a cloud service that can produce MS Word and PDF output via a simple api. The report or document templates are either Word or Open Office documents which can be edited and maintained by non-developers. Once uploaded to the system your application can then simply call the service and specify the data to inject into the document(s) as either JSON or XML. The result is then streamed back, emailed, or placed in storage for access later. Output can be doc, pdf, or html.
The service offers a wide range of templating features and so supports quite complex reporting requirements.
The best thing we found was that cosmetic changes to the output could be handled by the document authors and not the developers which saved us heaps of valuable time (not to mention saving the sanity of our developers).
www.docmosis.com
If you want to build your documents in code, the OpenXML SDK is definitely the way to go. It is a very well designed API that makes full use of LINQ type syntax. One you're up to speed on it you will find it very powerful and easy to use.
With that said, you then have all the logic of your document in code. And change requires a change in your code and that tends to become a pain over time. If you want a system where you design the document in Word you've got a couple of choices - and Word automation is the worst. Even Microsoft says don't do Office automation on a server.
One of the best choices where you design in Word is Windward Reports (disclaimer - I'm the CTO there). With Windward you get the power and ease of Word for your design and new documents or revisions of existing documents don't require a change in code. Other products that take this approach are XpertDoc and SoftArtisans (although both of them do have a code component with each template).

Is there a pre-existing sulution using c# with the Excel Interops to template excel like jXLS does?

I'm looking for comments, alternative solutions and recommendations.
Background:
We currently have a CRUD app built on Websphere using the struts framework. We generate excel documents using a standalone C# application that is tied together to the web application using an ActiveX control. We pass XML that contains elements for each document. Under each document we have placeholders that contain a name and a value. The document generation application takes the name (either a cell reference or a named range) and a copy of the template from a file server. It then adds the data to all of the specified locations in the document and saves the document to the users "My Documents" folder. It then attempts to upload the documents to Documentum.
Current Problem:
One of the templates has grown to very large sizes. For the most part this is because of the amount of data that needs to be displayed. We breakdown the information into groupings. Each of these groupings needs to be able to display information for up to 20 pieces. Some of these tabs also need to display up to 100 sub elements for the pieces. Due to the current nature of the home built document generation framework, it's not possible to dynamically generate the different sections with a variable number of elements. This has recently started to cause problems with the maintenance of the template. If we need to make formatting changes, it needs to be replicated to not only every tab, but possibly for every instance within each tab.
I started to look at jXLS and it's templating abilities, but since it's java based it will be a hassle to integrate it with the c# application. The other alternatives would be to build jXLS like capabilities into our generation framework, integrate a third party library into the framework, or do the document generation on the Application server. I'd prefer to avoid reinventing the wheel, and would like to re use a library from somewhere.
I'd also like to not impact the existing work flow as much as possible. So the prefered order of solutions right now looks something like this.
1) use an Existing Library for .NET
2) Call the jXLS library from the DocumentGeneration framework.
3) Build in the templating capabilities to the Generation Framework
4) Use jXLS on the application server (Due to the way we have the process upload to Documentum)
What recommendations do you have for this?
I am not sure how much this will help you, but I have used NPOI in the past for generating XLS documents and it is quite easy to work with. NPOI is a .NET port of the Java POI, POI is used by jXLS internally.
I am not sure if it's functionality will suite your requirements, or at least be a starting point.
I've used Syncfusion's XLSIO component for excel templating along the lines of JXLS. It's .net and works pretty well, but it is a commercial product and licensing becomes expensive if you have lots of developers on the project.
If you find an open source port of JXLS do share!

Categories