You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@poi.apache.org by Peter Remec <pe...@gamadata.si> on 2017/03/03 08:25:06 UTC

SQL syntax highlighting in .docx file

I'm generating a .docx file using Apache POI. This file contains a lot of SQL code and is quite unreadable so I was thinking about coloring that code. Any idea how to achieve that? 

I understand that POI doesn't have some highlighter to complete this task. I'm just looking for some idea of how to highlight it during file generation with POI.

Thanks! 

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org


Re: SQL syntax highlighting in .docx file

Posted by Javen O'Neal <on...@apache.org>.
Are there any third party libraries that can lex SQL and return an rich
text string?

This would be the easiest way to avoid writing your own syntax highlighter
that understands the full SQL grammar.

Looks like there area bunch of online syntax highlighters that will produce
HTML output. [1]

You could also look at Eclipse's source code to see how they accomplish
syntax highlighting.

You might have better luck asking your question on StackOverflow or another
community where there are more people who have integrated syntax
highlighters into their application.

Once you have that, writing the colorized SQL to a Word document via POI is
easy.

If this is a one-off, you can also copy your SQL code to Notepad++ or any
other application which supports OLE/rich text on a clipboard, you can
paste the colorized text back to the Word document.

[1]
https://stackoverflow.com/questions/221570/what-code-highlighting-libs-are-there-for-java



On Mar 3, 2017 02:46, "Peter Remec" <pe...@gamadata.si> wrote:

I'm generating a .docx file using Apache POI. This file contains a lot of
SQL code and is quite unreadable so I was thinking about coloring that
code. Any idea how to achieve that?

I understand that POI doesn't have some highlighter to complete this task.
I'm just looking for some idea of how to highlight it during file
generation with POI.

Thanks!

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@poi.apache.org
For additional commands, e-mail: user-help@poi.apache.org

Re: SQL syntax highlighting in .docx file

Posted by Andreas Reichel <an...@manticore-projects.com>.
On Fri, 2017-03-03 at 08:25 +0000, Peter Remec wrote:
> I'm generating a .docx file using Apache POI. This file contains a lot of SQL code and is quite unreadable so I was thinking about coloring that code. Any idea how to achieve that? 
> 
> I understand that POI doesn't have some highlighter to complete this task. I'm just looking for some idea of how to highlight it during file generation with POI.


Peter,

for a similar task I use the combination of http://www.dpriver.com/pp/sqlformat.htm (for beautifying the SQL) and
RSyntaxTextArea (for Highlighting and RTF). Works like a charm, but you will need a Internet Connection.

Cheers
Andreas