java 如何在word文档中格式化Java代码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/11914798/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 06:55:01  来源:igfitidea点击:

How can I format Java code in word document

java

提问by Jury A

I need to write a report which may contain some Java code pieces. I need the code to appear colored and line numbered. How can I do this ?

我需要编写一份报告,其中可能包含一些 Java 代码片段。我需要代码显示颜色和行编号。我怎样才能做到这一点 ?

回答by www-0av-Com

Go to http://hilite.me/and copy from the preview pane directly to word (tested with MS Word2007). Supports line numbering, but not well. Quite good for snippets.

转到http://hilite.me/并从预览窗格直接复制到 word(使用 MS Word2007 测试)。支持行编号,但不是很好。非常适合片段。

回答by Reimeus

One way is to copy & paste directly from Eclipse. It preserves all the color formatting.

一种方法是直接从 Eclipse 复制和粘贴。它保留所有颜色格式。

回答by Kumar Vivek Mitra

-Well you can directly copy the things from anIDEto your Word Document.

-好吧,您可以直接将内容从 an 复制IDE到您的Word Document.

-And please make sure that you have switched on theLine Numberingof the Editor in the IDEbefore copying the code.

-在复制代码之前,请确保您已打开Line Numbering编辑器IDE的 。

回答by Kristóf Dombi

try to use this: http://quickhighlighter.com/

尝试使用这个:http: //quickhighlighter.com/

select with the line numbers copy and paste

选择与行号复制和粘贴

You can also use another online formatting tools, (http://stackoverflow.com/questions/206441/online-code-beautifier-and-formatter) but if you want the coloring to work after inserting to a word document, the highlihted source code html source must be inline styled.

您还可以使用另一种在线格式设置工具,(http://stackoverflow.com/questions/206441/online-code-beautifier-and-formatter)但是如果您希望在插入到 Word 文档后着色工作,高亮的源代码 html 源代码必须是内联样式的。

回答by Daniel Hári

  • You can copy with colors, but first you have to open all foldotherwise colors gone.

  • Line numbering copy is not working from Eclipse.

  • 您可以使用颜色进行复制,但首先您必须打开所有折叠,否则颜色会消失。

  • 行编号副本在 Eclipse 中不起作用。

Explanation with example: https://cmanios.wordpress.com/2012/03/08/copypaste-source-code-from-eclipse-to-microsoft-word/

举例说明:https: //cmanios.wordpress.com/2012/03/08/copypaste-source-code-from-eclipse-to-microsoft-word/