且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在服务器端加载word文档进行编辑和保存

更新时间:2023-11-27 22:26:46

试用DocX



https://docx.codeplex.com/ [ ^ ]



C#:使用DocX以编程方式创建和处理Word文档 [ ^ ]



或者公开赛XML SDK。
Try DocX

https://docx.codeplex.com/[^]

C#: Create and Manipulate Word Documents Programmatically Using DocX[^]

Or the Open XML SDK.


首先关于保存的文件丢失所有格式,我假设您指的是HTML文件格式。很遗憾没有更多的信息我不能确定为什么会出现这个问题,但我认为问题可能是您的输出文件使用外部CSS,您是否尝试过仅使用内联样式?



尽管如此,对于单词文档,您必须将它们转换为HTML内容,以便在任何WYSIWYG HTML编辑器中显示它们(这也包括CK编辑器)。如果你的文件都是新的(DOCX格式),我建议你试试这个:

使用PowerTools for Open XML将DOCX转换为高保真的HTML / CSS [ ^ ]



如果您需要两者的解决方案旧的(DOC)和新的单词格式然后我担心没有免费的解决方案(至少不是我的知识)。嗯......有Word的自动化,我不建议你在服务器端使用。
First regarding the saved file loosing all the formatting, I presume you are referring to HTML file format. Well unfortunately without more information I cannot say for sure why this issue occurs to you but I presume the problem may be that your output file uses external css, have you tried using only inline styling?

Nevertheless regarding the word documents you'll have to convert them to HTML content in order to display them in any WYSIWYG HTML editor (this includes CK editor as well). In case your documents are all newer (DOCX format) I would suggest you to try this out:
Transform DOCX to HTML/CSS with High-Fidelity using PowerTools for Open XML[^]

If you need the solution for both old (DOC) and new word format then I'm afraid there is no free solution (at least not to my knowledge). Well... there is Word's automation which I wouldn't recommend you to use on server side.