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 6 years ago.
Improve this question
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 ?
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.
One way is to copy & paste directly from Eclipse. It preserves all the color formatting.
- Well you can directly copy the things from an IDE to your Word Document.
- And please make sure that you have switched on the Line Numbering of the Editor in the IDE before copying the code.
try to use this:
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.
You can copy with colors, but first you have to open all fold otherwise colors gone.
Line numbering copy is not working from Eclipse.
Explanation with example:
https://cmanios.wordpress.com/2012/03/08/copypaste-source-code-from-eclipse-to-microsoft-word/
Related
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 4 years ago.
Improve this question
The image below describes what I want to do, so I'm supposed to add many values to this three tables.
I'm using the library docx4j
You can use content control databinding for this; docx4j's OpenDoPE convention allows you to repeat table rows. And more recent versions of Word have a concept of repeating content controls; see https://www.docx4java.org/blog/2015/01/word-2013-repeatingsection-content-controls-ready-for-prime-time/
In principle, docx4j supports both, but it'll be easier to get help with the OpenDoPE approach.
To get started, try invoice.docx from https://github.com/plutext/docx4j/tree/master/sample-docs/word/databinding which is an example of repeating table rows.
To merge invoice-data.xml (from the same dir) into it, use https://github.com/plutext/docx4j/blob/master/src/samples/docx4j/org/docx4j/samples/ContentControlsMergeXML.java
If you like this approach, you'll need to author your own input document; to do this, you can try the "friendly" Word AddIn at https://opendope.org/implementations.html
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 6 years ago.
Improve this question
I would like to be able to copy the content of an Excel cell, let's say B3 in tab (or sheet) "my sheet" into a word document.
I know exactly where to put the content of B3 into the word document, but I don't know how I can do it using Java.
I just finished a project that creates an excel workbook from scratch using java. First time doing it, but I would recommend Apache POI. To share some sources I found along the way here is an overview of core classes the library offers with some useful method descriptions.
And if you find this is something you may want to use here are a bunch of examples that I found quite useful.
My answer is as non-technical as they come, but hopefully this is helpful in some way.
Edit: Just to give an example, you could do something like:
Sheet sheet = new Sheet();
sheet.getRow(rowNumber).getCell(cellNumber).setCellValue(someValue);
And you can get fancy and iterate through every row, cell, column, etc. I found it to be pretty flexible. Even offers styling options
Edit2: Just realized you don't need to set the excel cell value. Oh well, there it is anyways. Still a useful library to use one way or the other though.
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 7 years ago.
Improve this question
I want to write my own desktop keyboard, that can be used to work with some programs like excel. I've already written all graphical stuff, but i can't find any information about redirecting program output to another program. I found Apache POI, but it can be used only to work with Microsoft documents. Is there, for example a buffer, where can I send my letters or chars in ASCII? And next to be shown in my document or note?
Is there, for example a buffer, where can I send my letters or chars in ASCII?
Yes. It's called the Clipboard. You can call Toolkit.getDefaultToolkit() and then use Toolkit.getSystemClipboard() to get it.
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
clipboard.setContents("Some ASCII Text", this);
Note that this is the same buffer used for copy (ctrl-c) and paste (ctrl-v) (or their platform specific counterparts).
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
im stuck on a simple question, i want to display formatted text in a swing control and keep on adding new values into it, i don't want to use .setText(.getText + text) for personal reasons, (something like the append method for text area is what I am looking for) I've tried JEditorpane, Textpane but all of them do not have append method. Which swing control should I use?
While JEditorPane has no append method, you can certainly add text to its Document via its insertString(...) method, and I suggest that you look into doing this.
Edit
You ask:
it worked it out but it seems it works like setText, all the previous data vanishes.. how do i keep the previous data ?
Are you correctly passing in the first parameter, the offset? This should be the length of the current Document.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 9 years ago.
Improve this question
I am currently trying to write an application which allows me to get the code of an image just like when you open an image in a text editor.
I thought about changing the extension of the file and setting up a bufferedreader?
I have no idea how to accomplish this. The best would be having the code from the image in a String or an array.
Any ideas?
Thanks in advance.
I don't know exactly what you mean by "code", but I suggest you use any kind of image library. Maybe this can help you. In the library you can then call methods such as getSize() and more.
EDIT: Is this the code you are looking for?
<x:xmpmeta xmlns:x="adobe:ns:meta/"><rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:dc="http://purl.org/dc/elements/1.1/"><dc:creator><rdf:Seq xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:li>Corbis</rdf:li></rdf:Seq>
</dc:creator><dc:rights><rdf:Alt xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"><rdf:li xml:lang="x-default">© Corbis. All Rights Reserved.</rdf:li></rdf:Alt>
</dc:rights></rdf:Description><rdf:Description rdf:about="uuid:faf5bdd5-ba3d-11da-ad31-d33d75182f1b" xmlns:tiff="http://ns.adobe.com/tiff/1.0/"><tiff:artist>Corbis</tiff:artist></rdf:Description><rdf:Description xmlns:xmp="http://ns.adobe.com/xap/1.0/"><xmp:Rating>3</xmp:Rating><xmp:CreateDate>2008-03-14T13:59:26.540</xmp:CreateDate></rdf:Description><rdf:Description xmlns:MicrosoftPhoto="http://ns.microsoft.com/photo/1.0/"><MicrosoftPhoto:Rating>50</MicrosoftPhoto:Rating></rdf:Description></rdf:RDF></x:xmpmeta>
Try regex and read the file as you suggested. Otherwise a JaxB parser might help if you manage to set it up right.
Text-Files != Binary-Files
First line from BufferedReader-Docu sais: "reads text ..."
Ok, we know images are not text. So you need to use any InputStream, so you have a File, you need the FileInputStream. Be warned: If you print those binary-data to console, it is automatically converted into text, some special binary-data may be skipped. You can not paste it into notepad and save the output as image again.