Developing a file format using continous saving and versioning through SharePoint - c#

Well, I found a lot of stuff to this question but unfortunately only bits and pieces and nothing that specific for someone who looks for a starting point.
Draft:
I plan a file format which is derived from BagIT. I want to implement it as a class library in c#.net.
Environment: Office 365 (SharePoint Document List) synced to Windows 10 by OneDrive.
This are the two planned features:
- "Versioning" or better "Diff", like for example in Word
- Continous saving also like in Word or better like in all Office apps
For those not familiar with this features: If you are working in Office 2017, and your file is saved on a SharePoint drive (don't know exactly about OneDrive privat), than you can swich on "continous saving" (don't know the english term). With this your work will always be saved and you don't need to save manually. Works on OneDrive and SharePoint.
If you have SharePoint and you are using the versioning feature of it, than you can Word (don't know of other Office apps) let show the differences between the versions.
The "don't knows" are not the point.
I am searching for an outline, a starting point. Is it possible at all or is it only usable by Microsoft (at the moment)?
So it is SharePoint and C# (.net)
Links would be nice,
an outline also for other readers/potential questioners would be better.
Thanks in advance.

No I found the answere myself. For all with the same question: It ist in the REST-API. With it you can download different versions and diff them yourself.
I didn't found continous saving, but I think it is somwhere in this documentation. If someone knew it right now, than it would be nice if you could shorten my search. Otherwise I will send the link when I find it myself.
Here the link:
https://learn.microsoft.com/en-us/onedrive/developer/rest-api/api/driveitemversion_get

Related

how can i open .pdf file in office word 2013(in c#) and save as it in .docx (code in c#)?

I want open Pdf file in c# codes , I want use office word 2013 (Microsoft.Office.Interop.Word) with c# and save as word file in c#, how can I it ?
Give the guy a break, it is his first question and he has actually created an account with a picture an everything so I genuinely believe he is here to learn.
I have just done a quick google and it looks as though there is no native support for this, I would suggest you search for a an api to do it. I found this one which gave you code but I have no idea if it is a good framework or not, the code sample they give is a little over complicated imo.
http://www.yiigo.com/guides/csharp/how-to-pdf-convert-word.shtml
If you are genuine then Good Luck. I would recommend looking at the way other people post questions in the future, there are a lot of people on here who help people out and sometimes it is hard to sift through all of the questions where it looks like the asker is wanting people to solve their problems because they can't be bothered.
`
Wrdapp= new Word.Application();
FileConverter converter=Wrdapp.FileConverters[5];
//For checking format name
converter.FormatName;
Wrdapp.Open("PDF file path",Format:converter.OpenFormat);`
The file will be converted if the converters are installed with office 2013 and above

How to generate report in word 2010 using c# , dot net, word templates, xml [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
We have a database application that stores data that we want to report in Microsoft Word.
Suppose all information of my customers is stored on a database system and I am now requested to create hundreds of word letters, reports that will be sent to my customers. These letters have the same content but different customer name, customer address, etc.
I want to make use of Office Word 2010 by creating document template with content controls using c# and .Net, sql as database to replace the content of this template.
I've been looking for articles on automating Word 2010 in C# and dot net and sql. Could someone give me a push in the right direction?
You can use Interop.Word in your program, but keep in mind that the available documentation is very scarce. I managed to develop my application looking at examples like this one from C-SharpCorner or this one from WindowsDevCenter. Even if the examples are old, you can get the main idea and get familiar with the syntax, and write your program afterwards with an updated version of Interop.Word (which has a slightly simpler syntax).
In your case, you should create a neat Word template, with bookmarks located in the places of your document where you will insert the customer information. Then you can open the template from your program and navigate it using those bookmarks, as you insert the information retrieved from your database.
There are other interesting alternatives to Interop.Word that you could try if you don't want to go too deep into Word automation, such as DocX (which doesn't even require Microsoft Word or Office to be installed) or Open XML (to generate .docx files).
I've used the Office.Interop assemblies in the past for this kind of functionality but this method carries a few distinct disadvantages:
Word must be installed on the machine where the code is running
The Interop assemblies actually start up Word in the background, so you have to be careful to dispose of everything properly and handle errors, otherwise you'll end up with Word processes wasting CPU/Memory on the host server
The APIs are not very pleasant to work with and documentation is somewhat scarce
I've also played with DocX and Open XML, both of which have their merits but tend to be slightly limited by comparison with Interop. My advice would be to attempt the functionality using DocX or Open XML and only fall back to Interop if you can't achieve the functionality any other way. There should be plenty of tutorials online for all three APIs.
Microsoft recommends OpenXml for any application running in a server process, and this approach would probably be one of the best for reducing dependencies (as others have mentioned). Here are some links to get you started:
Download OpenXml SDK 2.0: http://www.microsoft.com/en-au/download/details.aspx?id=5124
Useful Tutorials: http://msdn.microsoft.com/en-us/library/ff478255.aspx
So for start DO NOT USE INTEROP, i've been using it for the last 4 years, and i have to tell u it's not a good idea (it's really lost, and u'll hit lots of problems. It's actually written on Microsoft's site that you shouldn't use it for server side generation.
You should use the OpenXML SDK, i've actually just started using it but i have to say that even if it seems a bit harder to use, it's definetly a lot faster that using interop and the best thing is that know i don't need any programs from the Office suite to be installed on my pc, the downside is that i can't export to PDF or XPS anymore without a 3rd party library
You can find the sdk here
http://www.microsoft.com/en-us/download/details.aspx?id=30425
I suggest downloading the tool as well it's pretty useful.
This is a good tutorial to start with it really helped me a lot.
http://msdn.microsoft.com/en-us/library/office/bb448854.aspx
And u can also use the API documentation from the Productivity Tool which is on the same site as the sdk
I agree with others that the OpenXML SDK is a good way to go for the same reasons. I am in the midst of creating a similar kind of report generation as you are. The reports I need to generate unfortunately are very dynamic not only with data but with the layout.
If your layout does not need to change then I would strongly suggest using the SDK Tool, it lets you take any word document and generate the c# code for you to recreate the same exact doc. From that point all you have to do is replace the text with the data you want in the code.
You could make a generic report in word, get the code with the tool, then just do a search for the placeholder text in the code and replace that string with a variable. its as easy as text1.text = reportData;
I also find the SDK Tool a great way to learn the code, you can compare two files side by side and see how they differ in the code.
Your answer is OpenXML SDK.
goto Open XML SDK 2.5 for Microsoft Office
download OpenXMLSDKV25 and OpenXMLSDKToolV25
install sdk and productivity tool
open word and create your template document
open Open XML SDK Productivity Tool
open word document
right click on document name from Document Explorer and select reflect code
copy all generated code to your project
find and edit "Paragraph" or "Run" that you want replace with your data
I have used both interop and syncfusion to create reports (although I was generating an excel report but both technologies can be used to generate word reports also). My feedback :-
Although interop is included in most computers which have visual studio (not sure about non visual studio computers), usage of interop requires the presence of compatible microsoft excel also on the computer generating the report whereas syncfusion does not requires the presence of microsoft excel on the same computer.
If you plan to use asp.net, then interop is not supported (atleast it was not when I worked) whereas syncfusion is supported.
Link for syncfusion :-
http://www.syncfusion.com/products/aspnet/docio
Summary :- If you are developing a console application and server(where the application will be deployed) has microsoft office installed, then interop might be a good idea. Otherwise, you can have a look at syncfusion also.
You can usee Free .NET Word API to generate report in word 97 ~ 2010 using c#.
//Create word document
Document document = new Document();
document.LoadFromFile(#"..\..\..\..\..\..\Data\Fax.doc");
string[] filedNames = new string[]{"Contact Name","Fax","Date"};
string[] filedValues = new string[]{"John Smith","+1 (69) 123456",System.DateTime.Now.Date.ToString()};
document.MailMerge.Execute(filedNames, filedValues);
//Save doc file.
document.SaveToFile("Sample.doc", FileFormat.Doc);

Give users the ability to edit Word 97-2010 documents within a .NET application

I was wondering if anyone has any idea of any product/method to give my end users the ability to edit Word documents within our C#/.NET application, avoiding the use of Automation and separate instances of Word opening outside of the application. This is a possibility [backup plan!] - but one that I'd rather not have to implement (due to the amount of work involved and having users exit our application).
I know that I could possibly use the WebBrowser control - but from what I've been able to find -- support for this is sketchy at best, and things such as toolbars are not present, and it does not appear to work with Word 2010 anyway.
I've been evaluating a few products that claim to do this but many are lacking in features or produce compatibility errors within documents rendering them useless when opened in Word.
We are using Word 2003 and Word 2010. Our documents start out as .DOCX files through our custom merge/templating processes.
Any suggestions for products or other ideas would be great.
Edit:
We're creating documents without issue using OpenXML. Fun stuff, works really well. However, at the end of the day I would prefer to have users editing the created documents as well as legacy documents (created as .DOC files) within our .NET application directly. Unforunately, with Microsoft removing the ability to embed via ActiveX/OLE, etc. there isn't a way to do this. What I am looking for is a 3rd party product to achieve this, which should be virtually 100% compatible with both the .DOC and .DOCX formats.
For those asking why ? Security, ease of use, etc. We are storing documents in a database. Once I start dropping files on the filesystem and working with Automation support/macros, ... there's a lot of things that would have to be done to get the files back into the database / update, etc. This is made especially difficult since Word doesn't expose the raw bytes[] of a document and files must be saved as temporary files somewhere on the fs. Just a lot of headaches.
So, the "easiest" solution - embed Word [seems not possible] or use a 3rd party product that supports editing .DOC/.DOCX files.
An example is DevExpress XtraRichEdit control - unfortunately, while it supports a lot of nice Word-like/compatible features it only works with .DOCX files.. and isn't 100% feature complete, compared to Word.
The file structure of a word document is huge, it could take hundreds of man hours to program even limited .doc/docx support. What exactly is the reason for using your program to edit a word file over word itself?
I am not exactly sure how Word 2003 has .docx support though, my understanding is there was only a word viewer release when Office 2007 was released, it of course has been years since thats been a problem.
If you are going to actually do this only add support for .doc files since there is more information out there, you can allow word itself to handle the converstion to a .docx file if you want.
You are not going to find a third party product that does this. The amount of effort required to build an app that 100% supports the Word formats is beyond consideration. Not just every feature, but every bug as well would have to be duplicated. Considering the potential legal pitfalls of doing such, no one in their right mind would bother trying. The legal aspects, incidentally, is one of the primary reasons for the new formats.
Which means you have to go external. There are two really good options here.
One would be to hook into Office Live to give them the ability to edit Microsoft Documents online.
Another possibility is to just leverage Sharepoint in your application. It has built in methods for document workflow and integrates nicely with Office.
A third possibility would be to write your own word add-in which would take care of saving / loading the documents from your system. I'd go with the first two above before going this route.
This used to be supported through a feature called OLE Embedding. Support for it has been disappearing from Microsoft software and tools over the past 10 years. Notably .NET has no support for it whatsoever. Office was one of the last hold-outs with 2007 already getting pretty cranky about it. But this indeed looks to be completely gonzo in the 2010 edition. All download links to the DSOFramer control, a generic ActiveX embedding control were removed around the time that 2010 went into beta.
There's no future here, look at VSTO for the road ahead.
Word Automation Services and Office Web Apps (requires SP 2010).
Certainly not 100% coverage of Word features, but have you tried ASPOSE.Words.NET Total or TXTextControl.NET?

Generating a Word Document with C#

Given a list of mailing addresses, I need to open an existing Word document, which is formatted for printing labels, and then insert each address into a different cell of the table. The current solution opens the Word application and moves the cursor to insert the text. However, after reading about the security issues and problems associated with opening the newer versions of Word from a web application, I have decided that I need to use another method.
I have looked into using Office Open XML, but I have not found any good resources that provide concrete information on exactly how to use it. Also, someone suggested that I use SQL reporting services, but searching for information on how to use them, lead me nowhere.
Which method do you think is the most appropriate for my problem?
Code samples and links to good tutorials would be extremely helpful.
Thanks for all the answers, but I really did not want to pay for a plugin and using Word automation was out of the question. So I kept searching and eventually, through some trial and error, found some answers.
After throughly searching through Microsoft's site, I found some newer articles on the Office Open XML SDK. I downloaded the new tools and just started going through each them.
I then found the Document Reflector, which creates a class to generate XML code based off an existing Word Document (.docx). Using my Label Template Document and the code this tool generated, I went through and added a loop that appends table cells for each address. It actually proved to be fairly simple and way faster than using Word automation.
So, if you're still using Word automation check out the Office Open XML tools. Their surprisingly extensive for a free download from Microsoft.
Office Open XML SDK 2.0 Download
I use the Words plugin from Aspose.com to do mail merges (programming guide).
You can take a look show 137 and 138 on dnrTV (www.dnrtv.com). In these video's Beth Massi shows how to do some editing and mail merging with OpenXML. She does this by using the Open XML SDK and xml literals in VB. It requires no third party components. Also it doesn't require MS Office to be installed on the machine.
This video inspired me as a C# developed (and no VB experience) to do some XML manipulation in a separate dll in VB. I call into this dll from my C# application.
It is worth a try.
We have the product Aspose that tvanfosson has mentioned. The edition that we purchased works with SQL Reporting Services so it can be used with the scheduler for creating output. It is really a great product and we used in a system that needed to support Korean characters in the final document. It works great and was under $1K with support. Not bad.
The advantage of using a product like this is that you can continue to manage your data and the skill set required to produce the documents is at a level where a variety of developers can support its use.
Vanstee,
If you really want to do this in code, check out this post I just found on Google
http://kellychronicles.spaces.live.com/blog/cns!A0D71E1614E8DBF8!1364.entry
If you are using reporting services cant you just move the information in the word doc into a database table and read it from there, taking word out of the equation?

Sharepoint as template application

We have a site that needs to (as part of our process) generate a document (e.g. Word docx document) that is derived from data within our application merged with a template document. This document can be edited at run time by the user after it is generated. We know we are looking at a CMS like system (since the users will need to be able to edit/create new templates) but I was wondering if Sharepoint could be of better use (since we don;t need a lot of the overhead of a traditional CMS system). Can any sharepoint experts weigh in and give me some pointers of where to look.
I am working on a similar problem -- generating word documents from information stored in a SharePoint site. The real magic here relies on using Content Controls in office 2007 - as the new version of the Office suite is based on Office Open XML, generating documents from data is almost trivial.
Enabling the documents to be editable after creation is a simple configuration change that can be made either programmatically or in the document template itself. In fact I think the true value of the platform wills shine when you can see how easily you can your organizations business processes to SharePoint.
Getting content from deep within a segment of your company, through the various approval steps to the public facing internet site is breathtakingly simple, once everything is configured properly.
Here are some good blog posts on generating OOXML docs on the server
ECMA Office Open XML - Options for
Generating Word Documents (on the
server;))
Generating Word Documents on the
Server (Part 2) - Dynamically Adding
Content Controls / Structured
Document Tags (SDT) using
System.IO.Packaging
Note that clients DO NOT need to run Office 2007 to open these documents, you can either have a conversion process, or you can install the free compatibility packs for Office XP, 2000 & 2003
As far as SharePoint as CMS, I think its a pretty compelling proposition. There is definitely some configuration and implementation challenges, but I think that will be the case with any enterprise CMS package. One important consideration is the amount of traffic your CMS'd site will see. I don't think SharePoint is ready to scale up to google-esque traffic, but its certainly going to be good enough for a typical corporate internet presence.
Here is a list of some public sites that are running MOSS
Once you get past the hurdle of initial configuration, it becomes very easy to enable CMS tasks across the organization as it works so well on both sides of the Firewall.
I think its a great product, and amazed by its flexibility and extensibility.
jt
Infopath is the forms technology that Sharepoint people are going to recommend to you. Most Infopath forms features require a full MOSS installation and the associated licensing fees. I think you can acheive what you want here with just WSS however.
If DOCX files as the form template is a hard and fast requirement of your app you can;
Automate Word (physically isolate this), this is not officially supported by MS
Explore using OpenXML (assuming all clients are using Word 2007).
If you ultimately need to generate PDFs or Word 2003 DOC files as output you are stuck automating Word otherwise #2 is the most server friendly solution.
Either way I think you can use a SP document library to hold the DOCX files and your users can share and edit the templates with versioning this way. You can programatically access these files in your application specific code and perform the data merging 'out of band'.
Here is the component that generates document based on the custom template. The documents are generated from the sharepoint list ... so the data is pulled from the list item into the document on the fly:
http://store.sharemuch.com/products/generate-word-documents-from-sharepoint-list
Hope that helps,
Yaroslav Pentsarskyy
Blog: www.sharemuch.com
Sharepoint is not going to relieve you of the weight and baggage of a traditional CMS system. If anything it will increase your baggage compared with a lot of CMS tools out there.
So in short - dont look at Sharepoint - look elsewhere!

Categories

Resources