dotnet / Open-XML-SDK

Open XML SDK by Microsoft
https://www.nuget.org/packages/DocumentFormat.OpenXml/
MIT License
3.99k stars 545 forks source link

Compile Windows Application #514

Closed chandrab699 closed 6 years ago

chandrab699 commented 6 years ago

Before submitting an issue, please fill this out

Is this a:

If you have answered that this is a question, please ask it on StackOverflow instead of here. This issue tracker is meant to track product issues while StackOverflow excels at answering questions

---------------- Remove this line and above before posting ----------------

Description

How to create a Windows application to perform text changes on Word/Excel documents.

Repro I have a VBA script to modify Word document. If I create a VBA addin in word, source code will be revealed. I do not want to give out the source code of the VBA script. I want to refactor my code to C#, which could also my code faster. I want to create a windows application, which accepts a docx/xlsx document and make changes. Save the file back with a new name in the same location. The windows application should not reveal the code, if extracted in any way.

ThomasBarnekow commented 6 years ago

@chandrab699, this is not the right place to ask this kind of question. Please post this to stackoverflow.com or do some reading on how to write Office Add-ins in C#, using Visual Studio and the Visual Studio Tools for Office (VSTO), and on obfuscating C# code (which will othewise be as accessible as your VBA code).

chandrab699 commented 6 years ago

Thank you. I will search for that. I am closing this issue. @ThomasBarnekow One more query, I want to write a "find and replace" for Word and Excel. is built VBA faster or this OpenXML faster? unzip the docx, xlsx, find and replace using python? Which is faster of all?

ThomasBarnekow commented 6 years ago

One more query, I want to write a "find and replace" for Word and Excel. is built VBA faster or this OpenXML faster? unzip the docx, xlsx, find and replace using python? Which is faster of all?

@chandrab699 This depends on your use case.

  1. Do you want to do that from within your Word or Excel Add-in or do you want to build some external application?
  2. Do you want to search and replace within individual or multiple documents at the same time?
  3. Do the Word and Excel automation APIs support what you want to do?
  4. Do you have experience with Open XML and understand the markup in detail?

I'm offering a product called DokuMate (see http://dokumate.com) that supports advanced search and replace in Word, Excel, and PowerPoint (among many other things). I am using Open XML and can tell you that this is extremely fast but also extremely complex to build and requires a lot of knowledge of the Open XML markup. WordprocessingML markup is particularly complex and also recursive. And now two document types are equal.

How would you go about "unzip the docx, xlsx, find and replace using python?"

chandrab699 commented 6 years ago

@ThomasBarnekow

  1. I prefer to do it Add-in, if I can obfuscate the code and it's as fast as the external editor. External application is also fine. Depends on which is easier to build and maintain
  2. Individual file at a time.
  3. It should be a standalone applications. Individual users download the app to convert the their personal document
  4. I am above average with open xml markups.

How would you go about "unzip the docx, xlsx, find and replace using python?" I would use 7zip to unzip the file and work on document.xml and zip it back.

I need to just replace text between fields and perhaps change the fonts and some paragraph values.